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

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

Asked by 3 years ago

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

0
is "db" a StringValue or BoolValue? User#23252 26 — 3y
0
It's clearly a string value. Also, I just recommend not using a value for the debounce, but rather a variable. Dovydas1118 1495 — 3y
0
Also, please use UserInputService instead of Mouse.Keydown. Roblox doesn't recommend Mouse.KeyDown. Dovydas1118 1495 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

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
    )
Ad

Answer this question