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

(?) TweenService isn't tweening TextLabel to desired location.

I created a ModuleScript to be called to tween a part to the middle of the screen, but it doesn't tween to the desired location. Intead of {0.402, 0},{0.467, 0}, it tweens to {0, 0}, {0, 0}. I'm not sure what I'm doing wrong here. Thank you in advance.

local module = {}

function module.load()

	local TweenService = game:GetService("TweenService")
	local tweenInfo = TweenInfo.new(
		2.5, -- Time
		Enum.EasingStyle.Sine, -- EasingStyle
		Enum.EasingDirection.InOut, -- EasingDirection
		0, -- RepeatCount (when less than zero the tween will loop indefinitely)
		false, -- Reverses (tween will reverse once reaching it's goal)
		0 -- DelayTime
	)

	TweenService:Create(script.Parent.TextLabel, tweenInfo, {Position=UDim2.new({0.402, 0},{0.467, 0})}):Play()
	wait(5.5)
	TweenService:Create(script.Parent.TextLabel, tweenInfo, {Position=UDim2.new({0.402, 0},{-1, 0})}):Play()
	wait(2.5)
	script.Parent:Destroy()
end

return module

1 comment

0

try removing the "{" and the "}" in the UDIM2 position in the tweens.

1 answer

✓ Accepted answer

Hey there!

Ok, instead of using TweenSerivce to tween the TextLabel's position, you can use the function TweenPosition() which is used for all GuiObjects.

TextLabel:TweenPosition(UDim2.new(XScale,XOffset,YScale,YOffset),EasingDirection,EasingStyle,AmountOfTime,Override)

or use click on the TweenPosition() function link I gave above, and I see that you are using brackets ({}) inside the UDim2 position. In Lua, brackets are known as tables, and it wouldn't be correct to have a table in a function that only accepts numbers. If you still wanted to use a table, you could use unpack():

TextLabel:TweenPosition(UDim2.new(unpack({XScale,XOffset,YScale,YOffset}),EasingDirection,EasingStyle,AmountOfTime,Override))

I hope I helped.

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