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

The GUI does not appear when you touch a part?

Asked by 7 years ago

Why does not a GUI appear in the Studio on LocalServer? In this case, in the usual test of the Studio, it appears. The text is in LocalScript

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character

script.Parent.Touched:connect(function(touchPart)
    if touchPart.Parent == game.Players.LocalPlayer.Character then
        game.Players.LocalPlayer.PlayerGui.HUD.LowerHud:TweenPosition(UDim2.new(0,0,1,0),"Out","Bounce",0.3)
    end
end)

script.Parent.TouchEnded:connect(function()

    game.Players.LocalPlayer.PlayerGui.HUD.LowerHud:TweenPosition(UDim2.new(0,0,1.2,0),"Out","Bounce",0.3)
end)



1 answer

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
7 years ago

If this helps, please be sure to accept my answer. I have left some comments for you to read.

script.Parent.Touched:connect(function(touchPart)
    local player = game.Players:GetPlayerFromCharacter(touchPart.Parent) --this is how you get the player from the character. The character is "touchPart.Parent".
    if player then --you can't get the localplayer in a serverscript. This is the way to check if a player touches.
        player.PlayerGui.HUD.LowerHud:TweenPosition(UDim2.new(0,0,1,0),"Out","Bounce",0.3)
    end
end)

script.Parent.TouchEnded:connect(function()
    local player = game.Players:GetPlayerFromCharacter(touchPart.Parent)
    player.PlayerGui.HUD.LowerHud:TweenPosition(UDim2.new(0,0,1.2,0),"Out","Bounce",0.3)
end)

Ad

Answer this question