Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My GUI won't appear when a player dies. Please help?

Asked by 4 years ago
Edited 4 years ago

I have a GUI gun giver for a gun game and the script keeps interfering with the GUI so it does not appear when a player dies. (Yes, ResetonSpawn is enabled.)

Here is my code:

player = script.Parent.Parent.Parent
backpack = player.Backpack

function chooseClass(class)
    for i, v in pairs(backpack:GetChildren()) do v:remove() end
    for i, v in pairs(class:GetChildren()) do
        if v:IsA("Tool") then
            v:clone().Parent = backpack
        elseif v:IsA("HopperBin") then
            v:clone().Parent = backpack
        end
    end

    script.Parent.Main.Visible = false
    script.Parent.Title.Visible = false
end

function onHumanoidDied(humanoid, player)
    script.Parent.Main.Visible = true
    script.Parent.Title.Visible = true
    end

for i, v in pairs(script.Parent.Main:GetChildren()) do
    v.MouseButton1Up:connect(function () chooseClass(v) end)
end

0
Are you reciving any errors in the studio output or developer console? moo1210 587 — 4y
0
Change v:remove() into v:Destroy() and change v.MouseButton1Up:connect to v.MouseButton1Up:Connect LennyPlayzYT 269 — 4y

Answer this question