Glitch with physics and bullets

For my game’s guns, whenever they are shot a localscript tells a serverscript to fire remoteventa, while also telling a bindable event to fire. remoteeventa tells every client except the player who fired it to render a bullet. The bindable event renders that same bullet, but the bindableevent’s bullet can tell the server to damage whatever it hits (unlike remoteeventa’s bullet). But, the bullets have a weird arc whenever they travel. There is a video included that shows this happening.

part that matters in the localscript that is inside the gun

local ray1 = Ray.new(script.Parent.Barrel.Position,(mouse.Hit.p-script.Parent.Barrel.Position).unit*50)
local _,pos,part = workspace:FindPartOnRayWithWhitelist(ray1,{})
fireanim:Play()
local positiontofireto = pos+Vector3.new(math.random(-(module.accuracy),module.accuracy),math.random(-(module.accuracy),module.accuracy),math.random(-(module.accuracy),module.accuracy))
local event = game.Players.LocalPlayer.PlayerGui.GunGui.RenderBulletBindable
event:Fire(plr,"Bullet",script.Parent.Barrel.Position,CFrame.new(script.Parent.Barrel.Position,positiontofireto).LookVector*module.bulletspeed,module.damage,module.experience)
script.Parent.Fire:FireServer(positiontofireto,script.Parent.Barrel.CFrame.p)

part that matters in the localscript that renders the bullet

local bullet = projectiles[projectile]:Clone()
bullet.Position = startpos
bullet.BodyVelocity.Velocity = velocity
bullet.Parent = workspace.ProjectilesFolder
bullet.CFrame = CFrame.new(startpos,mouse.Hit.p)*CFrame.Angles(0,90,0)

video link

4 Likes

Alright so inside the bullet there is a bodyvelocity, but the P property was set to 1250. I just increased it to 20000 and it works like a charm.

3 Likes