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

What does this Output error mean?

Asked by 9 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

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)
0
The code around the line that is throwing that error would be nice to include. Unclear 1776 — 9y
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.. LostPast 253 — 9y
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. Unclear 1776 — 9y
0
I added the code Coolviper630 95 — 9y

1 answer

Log in to vote
2
Answered by
Unclear 1776 Moderation Voter
9 years ago

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".

0
Thank you. :D Coolviper630 95 — 9y
Ad

Answer this question