I want to make my gui move smoother. But the animation doesn’t work? Simply the GUI just pops up on the screen, nothing else, no animation. Please help
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("FunZone"):WaitForChild("Transition")
local frame = script.Parent
Event.OnClientEvent:Connect(function(timer)
frame.Visible = true
frame:TweenPosition(UDim2.new(0, 0, 0, 0),"In","Circular",1)
wait(timer)
frame:TweenPosition(UDim2.new(1, 0, 0, 0),"In","Circular",1)
frame.Visible = false
end)
Make sure to originally move the Frame to another location. If it’s already set to (0, 0, 0, 0) then it will appear to not change. So, to fix this, first set the position outside of the viewport. For example,
I admit it, its my first time using TweenPosition, those are the properties and the path:
The local script inside has the code and the frame is the “Transition”. What I’m trying to make is the frame to come from the right side of the screen to the middle, wait on that timer value and then go back.
You need to use Enum not text where you try to tween like Enum.EasingStyle.Circular i can’t text it now and i don’t remeber names of this Enums, sorry i will try to help you soon.
Ensure that the OnClientEvent event is being fired properly by the server-side code that is responsible for triggering it. If the event is not being fired, then the client-side code will not execute.
In your current script, the issue might be due to the fact that the GUI is being hidden immediately after the second Tween finishes. To make sure the second Tween completes before the GUI is hidden, you can use the TweenFinished event. Here’s the updated script:
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("FunZone"):WaitForChild("Transition")
local frame = script.Parent
Event.OnClientEvent:Connect(function(timer)
frame.Visible = true
local tweenIn = frame:TweenPosition(UDim2.new(0, 0, 0, 0), "In", "Circular", 1, false)
tweenIn.Completed:Wait() -- Wait for the tween to finish
wait(timer)
local tweenOut = frame:TweenPosition(UDim2.new(1, 0, 0, 0), "In", "Circular", 1, false)
tweenOut.Completed:Wait() -- Wait for the tween to finish
frame.Visible = false
end)
In this script, I’ve added the false argument to the :TweenPosition() function calls to disable the automatic play. This allows you to wait for the TweenFinished event to make sure the tweens complete before proceeding with the script.
Now, the GUI should smoothly slide in and out according to the timer value.
The Completed:Wait() event doesn’t exist for these types of tweens. It only returns a boolean value.
You can only make tweens that have it with TweenService:Create(...) , such as:
local tweenOut = game:GetService("TweenService"):Create(frame, TweenInfo.new(1, "Circular", "In"), {Position = UDim2.new(1, 0, 0, 0)})
tweenOut:Play() -- You need to play it first so the Completed event works.
tweenOut.Completed:Wait() -- Now the event is available as it's made by the service itsself.