Hello, I have a Gui that gets tweened on when one out of 4 buttons are pressed. The Gui that is currently In the way should get tweened off and then teleported back to its original position (on the other side of the screen but not showing due to clip descendants). The issue that Im having is that the Gui gets tweened but doesn’t get teleported back and sometimes gets stuck and forgotten about in the middle of the scene.
My code:
local currFrame = EquipFrame
local ChangeDebounce = false
local function ChangeMainFrame(frame)
if ChangeDebounce == false then
ChangeDebounce = true
currFrame:TweenPosition(UDim2.new(-0.5,0,0.5,0),Enum.EasingDirection.In, Enum.EasingStyle.Sine, 1)
frame:TweenPosition(UDim2.new(0.5,0,0.5,0),Enum.EasingDirection.In, Enum.EasingStyle.Sine, 1)
currFrame.Position = UDim2.new(-1.5,0,0.5,0)
currFrame = frame
ChangeDebounce = false
end
end
Button1.MouseButton1Click:Connect(function() -- same function for other buttons but different ButtonFrame
ChangeMainFrame(ButtonFrame)
end)
Hey there! Your setting the denounce to true, and immediately after that you set it to false. This makes denounce not useful, make sure to add like a wait in between it, so it has time to process everything. Like this.
local currFrame = EquipFrame
local ChangeDebounce = false
local function ChangeMainFrame(frame)
if ChangeDebounce == false then
ChangeDebounce = true
currFrame:TweenPosition(UDim2.new(-0.5,0,0.5,0),Enum.EasingDirection.In, Enum.EasingStyle.Sine, 1)
frame:TweenPosition(UDim2.new(0.5,0,0.5,0),Enum.EasingDirection.In, Enum.EasingStyle.Sine, 1)
currFrame.Position = UDim2.new(-1.5,0,0.5,0)
currFrame = frame
wait(1.3) -- You prob want to wait 1.3 seconds, since the tween's duration is 1 second and you want to give the script time to process
ChangeDebounce = false
end
end
Button1.MouseButton1Click:Connect(function() -- same function for other buttons but different ButtonFrame
ChangeMainFrame(ButtonFrame)
end)
Tell me if this solved the problem if it didn’t get back to me.
This fixed the issue of it getting stuck in the center of the screen but it still isn’t being moved back to the original position which is (-1.5,0,0.5,0)
ok, I had to change some things because the other file had private info on it but the file structure is the same and im still getting the same issue. I also have an Issue where if you click the button that already has the gui on screen then it will go off screen.
Alright, sorry for the late reaction, was busy with some other things. I rescripted it for you and it should work now. I also explained everything I did.
why Enum.EasingDirection.In, Enum.EasingStyle.Sine, 1 ?
You juste need to use "In", "Sine", 1, true
This is better:
local currFrame = EquipFrame
local ChangeDebounce = false
local function ChangeMainFrame(frame)
if ChangeDebounce == false then
ChangeDebounce = true
currFrame:TweenPosition(UDim2.new(-0.5,0,0.5,0),"In", "Sine", 1, true)
frame:TweenPosition(UDim2.new(0.5,0,0.5,0),"In", "Sine", 1, true)
currFrame.Position = UDim2.new(-1.5,0,0.5,0)
currFrame = frame
wait(1.3) -- You prob want to wait 1.3 seconds, since the tween's duration is 1 second and you want to give the script time to process
ChangeDebounce = false
end
end
Button1.MouseButton1Click:Connect(function() -- same function for other buttons but different ButtonFrame
ChangeMainFrame(ButtonFrame)
end)
Not really, since then the script doesn’t work anymore. Look into the file, there are multiple buttons, with the script you sent you can only use one button and the bugs aren’t fixed either.