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

Did Roblox :TweenPosition Broke? My Script isn't working. is it because of a different reason?

Here's my script;

local plr = game.Players.LocalPlayer
local SB = script.Parent:WaitForChild('StartButton')
local OI = script.Parent:WaitForChild('OrangeImage')
local OT = script.Parent:WaitForChild('OrangeText')
local CB = script.Parent:WaitForChild('CombatHeros')
local String = CB.WTS.Value
local Length = string.len(String)


OI:TweenPosition(UDim2.new(0.3, 0,0.4, 0),'In','Bounce',4)
OT:TweenPosition(UDim2.new(0.45, 0,0.39, 0),'In','Sine',2)
SB:TweenPosition(UDim2.new(0.53, 0,0.75, 0),'In','Bounce',1)
for i = 1, Length do
	CB.Text = string.sub(String,1,i)
	wait(0.3)
end

The Tween Doesn't work and goes straight to the loop. How come it doesn't tween? Is there a way to fix it? This is a local script inside a screen GUI. Should I add game.Player.PlayerAdded:Connect(function() ? I'm not sure. I want this to run when the player joins. This is like an intro GUI.

Please answer with examples so I can understand.

Thank you for reading

3 comments

1

Im not sure, but i think tweens dont move to the next line once each one is done. It just keeps running through. add waits corresponding to the tween time after each tween

0

Is it because you're using ' instead of "?

0

No

1 answer

✓ Accepted answer

I tested your script (using random gui objects) and it tweens just fine. I assume your problem is what SpyGuyTBM guessed - that you want the for loop to run after the tweens are done. You can either follow SpyGuyTBM's advice and add wait commands or make use of TweenPosition's callback function, like so:

OI:TweenPosition(UDim2.new(0.3, 0,0.4, 0),'In','Bounce',4, function()
	OT:TweenPosition(UDim2.new(0.45, 0,0.39, 0),'In','Sine',2, function()
		--etc
	end)
end)

There are more elegant solutions, but they're more complicated.

If your problem is that you don't see any Tweening at all, make sure that you're seeing the same gui objects that your script is modifying. (ex, maybe they're modifying a duplicate that isn't even Visible, or is behind some other gui?)

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