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

What does this error mean?

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

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.

2 comments

0

Still says the same thing :/

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.

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