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

What does this error mean?

Asked by 9 years ago

So this script is supposed to move a part forward but an error message pops up that says this: bad argument #1 to '?' (Vector3 expected, got userdata) and I don't know what that means, here is the localscript:

plr = game.Players.LocalPlayer
mouse = plr:GetMouse()
function w(key)
    if key:lower() == "w" then
        script.Disabled = true
        workspace.Char.Position = workspace.Char - Vector3.new(0,0,1)
        script.Disabled = false
    end
end
mouse.KeyDown:connect(w)

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

You tried to set workspace.Char's Position to a UserData.. an instance. Position only takes the Vector3 Scale as an argument, or anything that returns a Vector3.

Also I don't have any idea why you're disabling the script. By disabling the script you're discontinuing any code after the disabling action.

Try dis;

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()

mouse.KeyDown:connect(function(key)
    if key:lower() == "w" then
        workspace.Char.Position = workspace.Char.Position - Vector3.new(0,0,1)
    end
end)

Also, make sure workspace.Char isn't nil.

0
Still says the same thing :/ Senor_Chung 210 — 9y
0
I fixed it never mind. On line six i put 'workspace.Char.Position = workspace.Char.Position - Vector3.new(0,0,1)' and that seemed to fix it. Senor_Chung 210 — 9y
Ad

Answer this question