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

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

Asked by 5 years ago

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. ```lua 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 ```

0
try removing the "{" and the "}" in the UDIM2 position in the tweens. mybituploads 304 — 5y

1 answer

Log in to vote
0
Answered by
blockmask 374 Moderation Voter
5 years ago

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.

Ad

Answer this question