Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
Vid_eo 126
8 years ago

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

Log in to vote
0
Answered by 8 years ago

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)
Ad

Answer this question