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

TweenSize error Unable to cast string to token???

Ok so i am making a GUI that will change its size and I get the error Unable to cast string to token

Frame = game.StarterGui.ScreenGui.Play.Frame
Button = script.Parent
-------------------------------------------------------------------------------------------------
Button.MouseEnter:Connect(function()
	
	Frame:TweenSize(
		UDim2.new(0.022, 0,0.593, 0),
		"out",
		"Sine",
		.3,
		true
	)
end)

Button.MouseLeave:Connect(function()
	Frame:TweenSize(
		UDim2.new(0, 3, 0, 46),
		"out",
		"Sine",
		.3,
		true
	)
end)

1 answer

✓ Accepted answer

On the TweenSize function, directly saying "out" or "sine" using strings wont work. What to do instead is given below:

Frame = game.StarterGui.ScreenGui.Play.Frame
Button = script.Parent
------------------------------------------------------------------
Button.MouseEnter:Connect(function()

    Frame:TweenSize(
        UDim2.new(0.022, 0,0.593, 0),
        Enum.EasingDirection.Out,
        Enum.EasingStyle.Sine,
        0.3,
        true
    )
end)

Button.MouseLeave:Connect(function()
    Frame:TweenSize(
        UDim2.new(0, 3, 0, 46),
        Enum.EasingDirection.Out,
        Enum.EasingDirection.Sine,
        0.3,
        true
    )
end)

You should use Enum.EasingDirection and Enum.EasingStyle to run tweening functions. Other examples are like: Enum.EasingDirection.In, Enum.EasingStyle.Linear etc.

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