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 4 years ago
Edited 4 years ago

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

CODE:

01local Inventory = script.Parent.Parent
02local CloseInventory = script.Parent
03 
04CloseInventory.MouseButton1Click:Connect(function()
05    Inventory:TweenPosition(
06        UDim2.new(0.459, 0,1, 1),
07        "OutIn",
08        "Sine",
09        3,
10        true,
11        nil
12        )
13end)

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 — 4y

1 answer

Log in to vote
0
Answered by
Pupppy44 671 Moderation Voter
4 years ago
Edited 4 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:

01local Inventory = script.Parent.Parent
02local CloseInventory = script.Parent
03 
04CloseInventory.MouseButton1Click:Connect(function()
05    Inventory:TweenPosition(
06        UDim2.new(0.459, 0,1, 1),
07        Enum.EasingDirection.InOut, -- InOut, not OutIn lol
08        Enum.EasingStyle.Sine,
09        3,
10        true,
11        nil
12        )
13end)

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 — 4y
Ad

Answer this question