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

My death screen script appears in the studio but not in the game?

Asked by 7 years ago
Edited 7 years ago
1game.Players.LocalPlayer.Character:WaitForChild('Humanoid').Died:connect(function()
2    script.Parent.Parent.Frame.Visible = true
3end)

3 answers

Log in to vote
0
Answered by 7 years ago

When you join a game it will take a small amout of time until the character is created. This delay is not included in studio. We commonly use the following code to wait for the character:-

1local localPlr = game:GetService('Players').LocalPlayer
2local char = localPlr.Character or localPlr.CharacterAdded:Wait() -- if the character is nil ie not loaded wait intil the character is added and return the character model to the char variable

Putting it all together

1local localPlr = game:GetService('Players').LocalPlayer
2local char = localPlr.Character or localPlr.CharacterAdded:Wait()
3 
4char:WaitForChild('Humanoid').Died:Connect(function()
5    script.Parent.Parent.Frame.Visible = true
6end)

Note this should be a local script in the gui.

I hope this helps.

0
Thx Goodbye_Fx 29 — 7y
0
np User#5423 17 — 7y
0
Hey do you know any website or video to help me with scripts? Goodbye_Fx 29 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

Use the transparency property instead of the visible property.

Log in to vote
0
Answered by 7 years ago

im sure this will work if not then ill fix it

1script.Parent.Parent.Frame:WaitForChild()
2game.Players.LocalPlayer.Character:WaitForChild('Humanoid').Died:connect(function()
3    script.Parent.Parent.Frame.Visible = true
4end)

Answer this question