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

How come this Tweening script only tweens once and then doesn't work?

This tweening script I just made only tweens once. I've checked it multiple times, and it should keep switching the values to true and false and opening and closing. Help! Also, it doesn't say 'Open Teleports!' when it should. I think there's a problem in the else.

Player = game.Players.LocalPlayer
PlayerGui = Player.PlayerGui
ScreenGui = PlayerGui:WaitForChild("ScreenGui")
Button = ScreenGui:WaitForChild("OpenClose")
ButtonBacking = ScreenGui:WaitForChild("ButtonBacking")
Open = false
local toggle = false

Button.MouseButton1Down:connect(function(open)
	if toggle == false then
ButtonBacking:TweenPosition(UDim2.new(0.5, -250, 0.5, -200), 'Out', 'Bounce', 2)
Button.Text = 'Close Teleports'
toggle = true
    else
ButtonBacking:TweenPosition(UDim2.new(1.5, 0, 0.1, 0), 'Out', 'Bounce', 2)
Button.Text = 'Close Teleports'
toggle = false
	end
end)






Thanks!

1 answer

Try this and see if anything changes

Player = game.Players.LocalPlayer
PlayerGui = Player.PlayerGui
ScreenGui = PlayerGui:WaitForChild("ScreenGui")
Button = ScreenGui:WaitForChild("OpenClose")
ButtonBacking = ScreenGui:WaitForChild("ButtonBacking")
local toggle = false

Button.MouseButton1Down:connect(function()
    if not toggle then
	ButtonBacking:TweenPosition(UDim2.new(0.5, -250, 0.5, -200), 'Out', 'Bounce', 2)
    else
	ButtonBacking:TweenPosition(UDim2.new(1.5, 0, 0.1, 0), 'Out', 'Bounce', 2)
    end
    Button.Text = 'Close Teleports'
    toggle = not toggle
end)

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