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

Tween not working even when script is right and there is no errors?

So I have this script:

local Button = script.Parent
Frame = script.Parent.Parent.Parent.Background1PC
start = script.Parent.Parent.Parent.Start

function onClick()

start:TweenPosition(UDim2.new(0.051, 0,1.5,0),"InOut","Sine",0.5)
wait(1.5)
Frame:TweenPosition(UDim2.new(0.05, 0,0.064, 0),"InOut","Sine",0.5)

end

Button.MouseButton1Click:connect(onClick)

And it works except that the start (script.Parent.Parent.Parent.Start) won't move after pressing the button but it should do as it is being tweened. If I change the script to delete it, however, it works.

I'm not really sure what's happening.

1 answer

✓ Accepted answer

What is going on here is once you have pressed the button once, the start and the Frame gui objects are already at the position you tweened it to last time. This means that when you hit the button again, nothing will move because the gui objects are already at the position you want them tweened to.

Possible solutions:

start:TweenPosition(UDim2.new(0.051, 0,1.5,0),"InOut","Sine",0.5)
wait(1.5)
Frame:TweenPosition(UDim2.new(0.05, 0,0.064, 0),"InOut","Sine",0.5)
start:TweenPosition( [wherever you want it] ,"InOut","Sine",0.5)

Or, you may have accidentally used the wrong variable. If you did, this will fix it:

start:TweenPosition(UDim2.new(0.051, 0,1.5,0),"InOut","Sine",0.5)
wait(1.5)
start:TweenPosition(UDim2.new(0.05, 0,0.064, 0),"InOut","Sine",0.5)

Hope this helps!

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