#Belt GUI Equip not working - RemoteEvents

1 messages · Page 1 of 1 (latest)

sonic epoch
#
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
        g.Parent = Character
    end
end)

Anyone able to help:

  1. I'm trying to make a Lanyard Equip Script using RemoteEvents.
  2. When I hit the GUI Button it's attached too, It kills me instantly.
  3. 0 Errors from what I can see in Output

What I need help with:

  1. Fixing my Script so the Lanyard actually gets equip
  2. Fixing my Script so it doesn't kill me instantly!
livid cosmos
#

you're destroying the hrp g = player.Character g.PrimaryPart:Destroy()

livid cosmos
#

did you write this code yourself?

sonic epoch
#

Yes.

livid cosmos
#

why is this in there? g = player.Character g.PrimaryPart:Destroy()

sonic epoch
#

Bc it's destroying the Middle Part on the Lanyard Model

#

And replacing it with the Torso

#

I think I've missed out smth though

#

as it wouldn't be killing me otherwise

livid cosmos
#

destroying the hrp will kill the character

sonic epoch
#

I

livid cosmos
#

explain what this code does g = player.Character g.PrimaryPart:Destroy()

sonic epoch
#

Wait

#

That means

#

g = the HRP

#

and then it's destroying it

#

I'm stupid...

livid cosmos
sonic epoch
#

HRP is linked with the Character, No?

livid cosmos
#

hrp is the character's primary part

sonic epoch
#

I know that...

#

Humanoid RootPart.

#

I'm wanting it to move G to the Character so it can be modified.

#

Then remove the Vest's Primary Part

livid cosmos
#

why do you have g = player.Character? do you think that moves the part to the character?

sonic epoch
#

I thought that moves the Model into the character.

#

Am I wrong?

livid cosmos
#

indeed you are

sonic epoch
#

It's worked like that in the past

livid cosmos
#

you probably meant to write g.Parent

sonic epoch
#

wait

#

local g = Vest:Clone() g = player.Character

livid cosmos
#

g.Parent = player.Character makes more sense than g = player.Character because all that does is change the value held in the variable

sonic epoch
#

g is the Vest Clone

#

Then it moves it to the Character

livid cosmos
#

it isn't after you do g = player.Character

sonic epoch
#

hmmm

#

let me try adding in g.parent

#

i'll get back to you

livid cosmos
sonic epoch
#

It doesn’t kill me now but it won’t equip it

#

And it says this in output now

#

Wait I haven’t set the primary part

livid cosmos
#

wait no that's the line after. still, there's no reason to destroy the primarypart. you should be welding to that

sonic epoch
#

It needs to change from the part called “middle” to the Torso of the player

#

Hense why it removes “middle”

sonic epoch