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

How do I fix my spreading shotgun?

I am working on a gun game and i get bugs on my guns. I have made a tweak on my shotgun where it spreads depending how long the distance is. But it only works when i aim at the sky and not the ground which ruins my Bullet holes. Here is a photo. Photo here

And here is the code

local Start = Tool.Handle.BulletStart.WorldCFrame.p 
local SD = (Start-Mouse.Hit.p).magnitude/100
local SX = math.random(-SD,SD)
local SY = math.random(-SD,SD)
local SZ = math.random(-SD,SD)
local ShotgunDirection = Config.ShotgunMode and Vector3.new(SX,SY,SZ) or Vector3.new(0,0,0)
local Direction = (Mouse.Hit.p - Tool.Handle.BulletStart.WorldCFrame.p + ShotgunDirection).unit
local BulletRay = Ray.new(Start,Direction * Config.Range)
local Hit,Position,Normal = workspace:FindPartOnRayWithIgnoreList(BulletRay,IgnoreList,false,true)
Fire:FireServer(Tool,Config,Position,Hit,Normal,v)

1 answer

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