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

Mouse's position is considered a number value?

Asked by 10 years ago

the error is: bad argument #2, to ? (Vector3 expected, got number)

local tgt1 = m.Hit.p
v.velocity = tgt1*100

Other things you should know before you call me out on it: 1: I left out most of the script on purpose, and left these two lines as they are linked as a problem. And I know that everything is defined. v is a bodyvelocity object m is the mouse of the player

0
You are certain you cannot use this line: v.velocity = Vector3.new() without the script erroring? adark 5487 — 10y

2 answers

Log in to vote
0
Answered by
m0rgoth 75
10 years ago

I think it is because Hit is nil for a brief moment at some point. This can happen if the player looks into the sky or anywhere there are no parts. To fix this, try this:

local target = m.Hit
if target ~= nil then
    local tgt1 = target.p
    v.velocity = tgt1*100
end
Ad
Log in to vote
-1
Answered by 10 years ago

Instead try Vector3.new(100,100,100). Reading from what the output said, 100 is a bad argument so try using a Vector3.

0
Same error. .3. lowvillan 10 — 10y
0
Darn. Hmm There just isn't enough information for me. soaprocks2 75 — 10y
0
He's actually multiplying a Vector3 (m.Hit.p) by 100, which should result in a Vector3. adark 5487 — 10y

Answer this question