Gui pops up late

Hello currently I made a Gui which pops up when a player touches a part.But it only pops up when the player dies.

Watch this video to understand more.
Gui video.wmv (364.8 KB)

can you show us your code?
(30 characters)

I just did this

script.Parent.Touched:Connect(function()

game.StarterGui.EndScript.Frame.Visible = true

end)

You can’t change the GUI from startergui, it doesn’t work like that. Instead, you need to change the present GUI in the player. Use: player.PlayerGui.ScreenGui etc. To get the player variable, make sure you include the parameter “Hit” that comes with the touches function. Then, use game.Players:GetPlayerFromCharacter(Hit.Parent)

This will return a nil value if it touches anything besides a player in the output, to prevent this make sure hit.parent has a humanoid with if Hit.Parent:FindFirstChild(“Humanoid”) then

2 Likes

Do something like this:

script.Parent.Touched:Connect(function (h)

game.Players:WaitForChild(h.Parent.Name).PlayerGui.EndScript.Frame.Visible = true
End)

Should work, but I typed it on mobile so I’m not sure

It would work but a more efficient way is to use :GetPlayerFromCharacter()

script.Parent.Touched:Connect(function (h)
    game.Players:GetPlayerFromCharacter(h.Parent).PlayerGui.EndScript.Frame.Visible = true
end)

I recommend not having it download a video to your PC, a lot of people don’t like to download files off the internet.

1 Like

Ah, I forgot about that lol. Looked over my script and I really messed it up.

--//hi lol
script.Parent.Touched:Connect(function(h)
   local p = h.Parent:GetPlayerFromCharacter()
p.PlayerGui.EndScript.Frame.Visible = true
end)