#Belt Equip via ScreenGUI Button not working

1 messages · Page 1 of 1 (latest)

rose nebula
#
local RepStorage = game:GetService("ReplicatedStorage")
local BeltClip = script.Parent.BeltClip
BeltClip.PrimaryPart = BeltClip.Chest:WaitForChild("Middle")

function WeldParts(part0,part1)
    local newWeld = Instance.new("Weld")
    newWeld.Part0 = part0
    newWeld.Part1 = part1
    newWeld.C0 = CFrame.new()
    newWeld.C1 = part1.CFrame:toObjectSpace(part0.CFrame)
    newWeld.Parent = part0
end

script.Parent.MouseButton1Click:Connect(function(Player)
    local Character = Player.Character
    local Torso = Character:WaitForChild("Torso")
    if Character:FindFirstChild(script.Parent.Parent.Name) then
        Character[script.Parent.Parent.Name]:Destroy()
    else
        local NewArmor = BeltClip:Clone()
        NewArmor:SetPrimaryPartCFrame(Torso.CFrame)
        NewArmor.PrimaryPart:Destroy()
        for _, part in pairs (NewArmor:GetChildren()) do
            if part:IsA("BasePart") then
                WeldParts(Torso, part)
                part.CanCollide = false
                part.Anchored = false
            end
        end
        NewArmor.Parent = Character
    end
end)

It's a Local Script within a Screen GUI Button, Why won't it work :(

gusty viper
#

no errors?

rose nebula
#

I'm trying to add a Remote function in

#

It needs to weld itself to the player,

#

Could you help me fix this script?

#
local UniformPanel = game.ReplicatedStorage["Uniform Panel"]
local Event = UniformPanel["Belt Clip"]
local Vest = UniformPanel.Components.BeltClip

function WeldParts(part0,part1)
    local newWeld = Instance.new("Weld")
    newWeld.Part0 = part0
    newWeld.Part1 = part1
    newWeld.C0 = CFrame.new()
    newWeld.C1 = part1.CFrame:toObjectSpace(part0.CFrame)
    newWeld.Parent = part0
end

Event.OnServerEvent:Connect(function(player, id)
    if player.Character:FindFirstChild("BeltClip") then
        player.Character:FindFirstChild("BeltClip"):Destroy()
    end

    if not player.Character:FindFirstChild("Beltclip") then
        local g = Vest:Clone()
        g = player.Character
        WeldParts()
    end
end)```
rose nebula
gusty viper
#

firstly, if you add a clip on the client side it won't be visible on the server. i presume it's already there on the server?

gusty viper
#

i'm not sure what your setup is now that you've changed it

rose nebula
#

I've got 1 Event in Rep Storage

nocturne girderBOT
#

studio** You are now Level 7! **studio

rose nebula
#

a Local script under the button

#

and a script in SSS

#
local UniformPanel = game.ReplicatedStorage["Uniform Panel"]
local Event = UniformPanel["Belt Clip"]
local Vest = UniformPanel.Components.BeltClip

function WeldParts(part0,part1)
    local newWeld = Instance.new("Weld")
    newWeld.Part0 = part0
    newWeld.Part1 = part1
    newWeld.C0 = CFrame.new()
    newWeld.C1 = part1.CFrame:toObjectSpace(part0.CFrame)
    newWeld.Parent = part0
end

Event.OnServerEvent:Connect(function(player, id)
    local Character = player.Character
    local Torso = Character:WaitForChild("Torso")

    if player.Character:FindFirstChild("BeltClip") then
        player.Character:FindFirstChild("BeltClip"):Destroy()
    end

    if not player.Character:FindFirstChild("Beltclip") then
        local g = Vest:Clone()
        g = player.Character
        g:SetPrimaryPartCFrame(Torso.CFrame)
        g.PrimaryPart:Destroy()
        for _, part in pairs (g:GetChildren()) do
            if part:IsA("BasePart") then
                WeldParts(Torso, part)
                part.CanCollide = false
                part.Anchored = false
            end
        end
    end
end)

Remote Script in SSS