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

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

Asked by
qu_uo 0
3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by
Y_VRN 246 Moderation Voter
3 years ago

(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.

Ad

Answer this question