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

How do i change the position of a Gui object smoothly?

2 answers

✓ Accepted answer

Just an easy example for TweenPosition (local script at StarterCharacterScripts, but with RemoteEvents (in a Filtering Enabled game) can be in a normal script):

local player = game.Players.LocalPlayer
local clone = game.ReplicatedStorage.ScreenGui:Clone()
clone.Parent = player.PlayerGui
player.PlayerGui.ScreenGui.Frame:TweenPosition(UDim2.new(0.5, -50, 0.5, -50), Enum.EasingDirection.Out, Enum.EasingStyle.Bounce)

line 04 is what you need, that's the example for TweenPosition.

EDIT: Point of this all is TweenPosition, and the link.

Hope this helps

1 comment

1

Thx it helped a lot!

If you want to smoothly move a GUI, use UDim2.new, if you want to modify the style of the movement, then visit this article on the different styles of movement -

https://developer.roblox.com/api-reference/enum/EasingStyle]

This has to be done in a Local Script, otherwise, the script will not play.

Here is how you could move a GUI, for example, using a TextButton to perform the task.

script.Parent.MouseButton1Click:Connect(function() -- When the text button is clicked.
	print("Clicked") -- Just a message to tell you if it's working or not.
	script.Parent:TweenPosition(UDim2.new(-0.15, 0, -5, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quart) -- Visit the linked article in this post to see what style fits your preference best!

--[[ (Number xScale, Number xOffset, Number yScale, Number yOffset)) This is the number order within the parenthesis]]--

end)

If this is the answer to your question, please feel free to let me know! I hope this helps you!

1 comment

0

I don't agree that this has to be in a LocalScript, as if someone using this in a FE server, with RemoteEvents, this should be in a normal script.

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