Hello, I present with an issue. I am trying to get the bullets to follow the mouse , but this wont work.
In the client script, it fires the server with information about the guns positon and the mouse position. And then in the server it starts calculating it, and makes it happen. Issue is, this isn’t working. Here is the error;
attempt to index a number value
Now here is the area where the server calculates;
function RandomVectorOffsetZoom(v, maxAngle) --returns uniformly-distributed random unit vector no more than maxAngle radians away from v
return (CFrame.new(Vector3.new(), v)*CFrame.Angles(0, 0, rng_v:NextNumber(0, 1.5*math.pi))*CFrame.Angles(math.acos(rng_v:NextNumber(math.cos(maxAngle), 1)), 0, 0)).LookVector
end
--Calculations
local extendedRay = Ray.new((gunTip.CFrame.p-mousehit.CFrame.p).magnitude, RandomVectorOffsetZoom(gunTip.CFrame.lookVector, math.rad(5)) * (range))
Here is client side;
local mousepos = mouse.Hit
timeTillNextShot = fireGun:InvokeServer("GUNNAME", gun, fireCount,mousepos)
If anyone knows how to fix this error, it would be appreciated!
As the script output error says, the first arguments is an error. It expects a vector3 and got a number.
The part that I qouted above shows the error you did, you’re trying to subtract a vector3 value with a number value,
This did not work. If you read;
local mousepos = mouse.Hit.p
When I tried making it mouse.Hit.CFrame.p , this still didn’t work. This is an invalid solution.