SO I recently scripted a new gun script for my top-down game. The problem I have is that the bullets kina freeze for a second after I shoot. I do not have any wait() statements in the function. So I don’t really understand what is happening.
2 Likes
It looks like a NetworkOwnership problem. The server is taking over control of the physics from the client. You can solve this by giving network ownership to the client/server using SetNetworkOwner()
how do I do that? I have never used something like that before
is it projectile.PrimaryPart:SetNetworkOwner(nil)
Is your game single player? If it is, you should set the network owner to the player for smoother movement.
Otherwise, yes, that is how you set network ownership to the server.
p.Parent = workspace
p.Massless = true
p.Name = "bullet"
p.CanCollide = false
p.Color = Color3.fromRGB(255, 255, 0)
p.Size = Vector3.new(0.1,0.1,5)
p.Transparency = 1
p.Position = han.Position
p.CFrame = CFrame.new(han.Position,hitpos)
p.Material = Enum.Material.Neon
p.PrimaryPart:SetNetworkOwner(nil)
local mesh = Instance.new("SpecialMesh")
mesh.MeshType = Enum.MeshType.Sphere
mesh.Parent = p
local body_vel = Instance.new("BodyVelocity")
body_vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
body_vel.P = 0
body_vel.Velocity = p.CFrame.lookVector * 700
body_vel.Parent = p
debris:AddItem(p,10)
So this is my bullet function
As p is your part and not a model it would be
p:SetNetworkOwner(nil)