Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The GUI does not appear when you touch a part?

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.