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

How to place a GUI in a Player's PlayerGui once a player has died?

Asked by 6 years ago

CharacterAutoLoad is set to false.

function onPlayerDied(player)
    script.StartMenu:Clone().Parent=game.Players.LocalPlayer.PlayerGui
end

Players.LocalPlayer.Character.Humanoid.Died():connect(onPlayerDied)

I keep getting this error:

13:58:09.416 - ReplicatedFirst.GUI:22: attempt to index field 'Character' (a nil value)

Thank you!

2 answers

Log in to vote
1
Answered by 6 years ago

Put this in Normal Script in workspace and put the Gui In it and name the GUI dead

function udead(whodat, whodatplr)
    whodat.Humanoid.Died:connect(function()
        script.dead:Clone().Parent = whodatplr.PlayerGui
    end)
end

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:wait()
    udead(plr.Character,plr)
    plr.CharacterAdded:connect(function(char)
        udead(char,plr)
    end)
end)
0
you don't need lines 2, 4, 8, 9 Vulkarin 581 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

Did you try to use WaitForChild?

Answer this question