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

How can I Tween a GUi's position when a ClickDetector is clicked?

this is the script i have right now script.Parent.MouseClick:Connect(function(pressed) if pressed then game.Players.LocalPlayer.PlayerGui.ScreenGui.checkin:TweenPosition(UDim2.new(0.483,-200,0.69,-200),'Out','Quint',0.3,true) end end)

1 answer

(Note: Please format your post correctly, and maybe add some more detail about what you want to achieve next time.)

To answer your question:

script.Parent.MouseClick:Connect(function(player) -- MouseClick event returns the player that clicked it.
	if player then
		-- LocalPlayer only works for LocalScripts. Since "player" returns a Player instance, use it to get the ScreenGui.
		player.PlayerGui.ScreenGui.checkin:TweenPosition(UDim2.new(0.483,-200,0.69,-200),'Out','Quint',0.3,true)
	end
end)

ClickDetector.MouseClick event returns a Player object, which is basically the player who clicked it.

Also, server scripts cannot access LocalPlayer, only LocalScripts.

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