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

Error "Unable to cast string to token", why?

Asked by 3 years ago
Edited 3 years ago

Hello. I am writing some scripts and while editing TweenPosition I had an error.

CODE:

local Inventory = script.Parent.Parent
local CloseInventory = script.Parent

CloseInventory.MouseButton1Click:Connect(function()
    Inventory:TweenPosition(
        UDim2.new(0.459, 0,1, 1),
        "OutIn",
        "Sine",
        3,
        true,
        nil
        )
end)

ERRORS:

Unable to cast string to token
Error happens on line 5

0
you have to type the full Enum.EasingStyleblablablabla.OutIn not just the name, also without quotes Amiaa16 3227 — 3y

1 answer

Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
3 years ago
Edited 3 years ago

You'll need to get the EasingStyle and EasingDirection from Enum. Enum is just something that stores a bunch of stuff, not really sure. Here's an example:

local Inventory = script.Parent.Parent
local CloseInventory = script.Parent

CloseInventory.MouseButton1Click:Connect(function()
    Inventory:TweenPosition(
        UDim2.new(0.459, 0,1, 1),
        Enum.EasingDirection.InOut, -- InOut, not OutIn lol
        Enum.EasingStyle.Sine,
        3,
        true,
        nil
        )
end)

Using a string for them will result in an error. Hope this helps!

0
Thank you, Pupppy44. I was watching old tutorial so I had that problem. ErktikyYT 89 — 3y
Ad

Answer this question