How to make a gui tween when a part is clicked

I have a gui already set up with a frame, and i wanted to ask since i couldn’t find any tutorial, how would u tween a gui once a click detector is used?

1 Like

You could use RemoteEvent to fire client when the click detector is clicked on the server side, and then tween the gui on the client side.

Or, simply do Players.Player.PlayerGui.ScreenGui.Frame on the server side and tween it. (not recommended)

1 Like

Why changing playergui from server side is not recommended?
Due to it becoming problematic to maintain in future?

1 Like

due to it being ugly

i learned about it just now, but i only want the player to individually see it, could i get an explanation?

ClickDetector on the Part gets clicked and fires the MouseClick event. Server listens for this MouseClick event and sends a RemoteEvent to the client to make it tween. On the Localscript, listen for the RemoteEvent to fire and use Tween Service to tween the GUI.

Your best bet is to use remote events
Simply add a new Remote Event into Replicated Storage and name it something that fits

This isn’t a full script, this is something that’ll probably work

--//Server script where the button is
local event = game.ReplicatedStorage:WaitForChild("TweenUi") --//Put the name of your event here
--//Local script in the gui
local event = game.ReplicatedStorage:WaitForChild("TweenUi") --//Put the name of your event here
    --//Tween code here

if you need help with the tween code or there’s an error just lmk.

Sorry for the late reply but the people above me have actually kind of explained it.

The method :FireClient() of a RemoteEvent only tells a specified client of the player to run the event, in which the specified client is passed as the first argument of the parameters. So if you would like to have the event happened on only a player, simply do RemoteEvent:FireClient(Player).

On the other hand, another method :FireAllClients() would instead tell all clients to run the event, therefore there is no argument of specified client(s) required. In this case, you can simply do RemoteEvent:FireAllClients().

An exceptional case is, when there is only one player in the server, :FireClient() and :FireAllClients() would essentially work the same way.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.