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

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

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

1 comment

0

you have to type the full Enum.EasingStyleblablablabla.OutIn not just the name, also without quotes

1 answer

✓ Accepted answer

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!

1 comment

0

Thank you, Pupppy44. I was watching old tutorial so I had that problem.

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