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

Bullet spread increases the closer your mouse is to your gun? [SOVLED]

Asked by 5 years ago
Edited 5 years ago

I have been working on scripting my first gun recently. And I have got most of it working except bullet spread.

The problem I am having is bullet spread increases the closer your mouse it to the barrel of your gun.

Heres a gif to show you an example.

https://gyazo.com/3435f34daf2a3a427ad27723abdf67b5

Heres my code for the ray script.

    local BulletRay = Ray.new(BarrelPosition, (Vector3.new(MousePosition.X + Random.new():NextNumber(-Spread, Spread), 
        BarrelPosition.Y, MousePosition.Z + Random.new():NextNumber(-Spread, Spread)) - BarrelPosition).Unit

I only want spread on the X and Z axis because my game is top down.

Thank you for your time :) Have a gooood dayyyyy

0
im kind of a noob to ray casting but maybe for the reference point(or whatever is linked to MousePosition) change it to HumanoidRootPart.CFrame * CFrame.new(0,4,0)?) the8bitdude11 358 — 5y
0
What do you mean> GottaHaveAFunTime 218 — 5y
0
instead of the mouse's position you use the humanoid's position plus 4 studs the8bitdude11 358 — 5y
0
I dont think that would work GottaHaveAFunTime 218 — 5y
0
why not? the8bitdude11 358 — 5y

Answer this question