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

What does this Output error mean?

I do not know what this output error "Unable to cast string to token" means? Can someone tell me what it means please, thank you.

hint = game.Workspace.MainScript.hint

hint.Changed:connect(function()
	script.Parent.Text = hint.Value
	if hint.Value == "" then
		script.Parent:TweenPosition(UDim2.new(0, 0, -0.1, 0),"Linear",2.4, "InOut")
	else
		script.Parent:TweenPosition(UDim2.new(0, 0, 0.1, 0),"Linear", 2.4, "InOut") -- Eror is on this line.
	end
end)

4 comments

0

The code around the line that is throwing that error would be nice to include.

0

String can only be used in arithmetic if it can be converted to a number. That is what it means. You probably have to put tonumber() around your string if it is a number..

0

If it could be added in the first place because the string represents a number, the string would actually be forcibly cast to a number without throwing an error. That error would also look something like "attempt to perform arithmetic on a string value" rather than the above.

0

I added the code

1 answer

✓ Accepted answer

You simply messed up the arguments to TweenPosition.

bool TweenPosition (
    UDim2 endPosition,
    EasingDirection easingDirection = Out,
    EasingStyle easingStyle = Quad,
    float time = 1,
    bool override = false,
    Function callback = nil
)

It should be corrected to...

script.Parent:TweenPosition(UDim2.new(0, 0, 0.1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 2.4)

Your error is probably from attempting to cast "InOut" to an Enum value, which is the "token".

1 comment

0

Thank you. :D

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