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

PlayerGui help please?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

What I am trying to do is when a player touches a part then the frame pops up on their own screen. The script is located in a part.

Part = script.Parent
Part.Touched:connect(function()
    game.Players.Name.PlayerGui.Gui.Frame.Visible = 0
end)

1 answer

Log in to vote
1
Answered by
Azmidium 388 Moderation Voter
9 years ago

Your main issue is that when you do game.Players.Name it returns the name of the player. There is no item in Player named NAME, therefore you cannot get the PlayerGui.

To get to the player gui you must do something like this:

Part = script.Parent
Part.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then   
        game.Players[hit.Parent.Name].PlayerGui.Gui.Frame.Visible = false -- Visible needs a bool
    end
end)

this will actually get the players gui. I think what you wanted was to actually get the players name and use that to find children inside Players.

Hope this helped!

Ad

Answer this question