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

Why did I get this error in my script? I was getting the error 'Unable to cast string to token?'

I was just writing a script. Then I got this error, 'Unable to cast string to token.'

Here is my code, The Error was on line 18.

local p = script.Parent.Parent
local m = game.Players.LocalPlayer:GetMouse()
local db = script.Parent.Parent.value
db.Value = "false"
m.KeyDown:connect(function(k)
	k = k:lower()
	if k == "z" then
		if (db.Value == "false") then
	
			p.Enabled = true
	

local j = script.Parent
	j:TweenPosition(
		UDim2.new(1, 0,0.018, 0),
		"Quad",
		2,
		true
	)
local db = script.Parent.value
			db.Value = "true"

		elseif (db.Value =="true") then


local j = script.Parent
	j:TweenPosition(
		UDim2.new(0.261, 0,0.476, 0),
		"In",
		"Quad",
		2,
		true
	)

			p.Enabled = false
			db.Value = "false"

		end
	end
end)

Any help would be greatly appreciated,

-Geo

3 comments

0

is "db" a StringValue or BoolValue?

0

It's clearly a string value. Also, I just recommend not using a value for the debounce, but rather a variable.

0

Also, please use UserInputService instead of Mouse.Keydown. Roblox doesn't recommend Mouse.KeyDown.

1 answer

✓ Accepted answer

You forgot to add an easingdirection to the tween.

 j:TweenPosition(
        UDim2.new(1, 0,0.018, 0),
	"Out", --Or In/InOut if you want
        "Quad",
        2,
        true
    )

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