So my gun projectile is having delays when shooting and it is firing the wrong way when it is firing in front of me (wierdly, this doesn’t happened when it fire in back of me.)
local cooldown = false
script.Parent.RemoteEvent.OnServerEvent:Connect(function(p,a,b)
if cooldown==false then
cooldown = true
script.Parent.yep.Sound:Play()
local sh = Instance.new("Part",workspace)
sh:SetNetworkOwner(nil)
sh.Size=Vector3.new(1,1,5)
sh.CanCollide = false
local x,y,z = CFrame.new(script.Parent.yep.Position,a.p):ToOrientation()
sh.CFrame = CFrame.new(script.Parent.yep.Position)*CFrame.fromEulerAnglesXYZ(x,y,z)
local bv = Instance.new("BodyVelocity")
bv.Velocity = Vector3.new(sh.CFrame.lookVector.X,sh.CFrame.lookVector.Y,sh.CFrame.lookVector.Z)*200
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.P = 500
bv.Parent = sh
sh.Transparency = .5
sh.Material = "Neon"
sh.BrickColor = BrickColor.new("New Yeller")
script.Parent.yep.PointLight.Enabled = true
script.Parent.yep.ParticleEmitter.Enabled = true
sh.Touched:Connect(function(c)
if c.Parent:FindFirstChild("Humanoid") then
if c.Parent.Humanoid.Health<=0 then
c.Parent.Humanoid.Health = c.Parent.Humanoid.Health-20
if c.Parent.Humanoid.Health<=0 then
p.leaderstats.Money.Value = p.leaderstats.Money.Value+50
end
end
end
end)
wait(.1)
script.Parent.yep.PointLight.Enabled = false
script.Parent.yep.ParticleEmitter.Enabled = false
game:GetService("Debris"):AddItem(sh,8)
wait(.9)
cooldown = false
end
end)
Here is my script. sh:SetNetWorkOwner(nil) is suppose to make it not delay because I saw that they use it in another post about projectile delay...Aparenty it doesn't work.
You’re calculating your velocity wrong, but I can’t tell you how to do it correctly because you’re variables are named ambiguously. What is p, a, and b?
Sorry, I don’t think I’ll be able to be of more help at this time. The code I provided is mathematically accurate. Here’s me using the same math here.
Here’s the place file that you can use to test it and see if there’s a difference between our code. The only possibility is that one of your positions sent to the remote function is incorrect or the wrong one.
ok nvm i figured it out
Basically I fire all clients on a remoteevent in the serverscript and then the localscript in a player recieves it and handles the part instance velocity (the serverscript still makes one but it’s invisible)