I made a spread system for my gun, but the problem is that the closer you are to the target, the more spread it is.
Script:```
local ray = Ray.new(FirePos.Position,(mouse.Hit.p-FirePos.Position + Vector3.new(math.random(-Spread,Spread),math.random(-Spread,Spread),math.random(-Spread,Spread))).unit*Range)
Video:
This is not the full script. The other parts are not necessary to my problem.
Unrelated, but Please do not use Ray.new() and workspace:FindPartOnRay() as those have been Deprecated due to the new Raycast system, Instead use RaycastParams and workspace:Raycast()
i tried making it work:raycast but i don’t know what to do on pos line, i tried a lot of things but they didn’t work
local ray = workspace:Raycast(FirePos.Position,(mouse.Hit.p-FirePos.Position--[[ + Vector3.new(math.random(-Spread,Spread),math.random(-Spread,Spread),math.random(-Spread,Spread))]]).unit*Range)
local hit = nil
local pos =
local ray = workspace:Raycast(FirePos.Position,(mouse.Hit.p-FirePos.Position--[[ + Vector3.new(math.random(-Spread,Spread),math.random(-Spread,Spread),math.random(-Spread,Spread))]]).unit*Range)
local hit,pos = ray.Position,ray.Instance
local ray = workspace:Raycast(FirePos.Position,(mouse.Hit.p-FirePos.Position + Vector3.new(math.random(-Spread,Spread),math.random(-Spread,Spread),math.random(-Spread,Spread))).unit*Range).Unit * whateverRangeYouWant