"Unable to cast token to float"

Whenever I try tweening a text label, it yields this error:
image

Not sure why, I’ve tried looking it up but no answers contain the solution to the problem I’m facing.

Code
local label = script.Parent.TextLabel
local tweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)

script.Parent.MouseEnter:Connect(function()
	label:TweenPosition(UDim2.new(1, 0, 0, 0), 0.5, Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, false)
	--tweenService:Create(label, tweenInfo, UDim2.new(1, 0, 0, 0))
end)

script.Parent.MouseLeave:Connect(function()
	label:TweenPosition(UDim2.new(2.347, 0, 0, 0), 0.5, Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, false)
	--tweenService:Create(label, tweenInfo, UDim2.new(2.347, 0, 0, 0))
end)

Help is appreciated

When you use GuiObject:TweenPosition() the parameters go as follows:

  1. End Position
  2. EasingDirection
  3. EasingStyle
  4. Time (in seconds)
  5. Override (optional)
  6. Callback (optional)

So this:

Should be this:

label:TweenPosition(UDim2.new(1, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false)

And this:

Should be this:
label:TweenPosition(UDim2.new(2.347, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.5, false)

1 Like

god why do these things have to be so precise in order wejhvwef
appreciate the help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.