I have been stuck on a problem like this for a while now, and I can’t seem to fix it.
I have a fast projectile that is supposed to explode on contact, and it works fine on the server but it explodes before contact on the client.
I have messed with networkownership for a while also, and it doesn’t seem to make a difference.
I have also recently been trying to use the new shapecast feature over the touched event. It doesn’t seem to make a difference.
Important Code (I don’t think the code really matters with a problem like this):
maxarc = coroutine.create(function()
while task.wait() do
local direction = clone.CFrame.UpVector * raycastLength
local result = workspace:Spherecast(clone.Position, raycastRadius, direction, raycastParams)
if result and result.Instance then
print(result)
local exaudio = game.SoundService.MortarAudio["Explosion [Quick]"]:Clone()
local exgfx = game.ServerStorage.BulletExplosionParticles:GetDescendants()
local PO = clone.ParticleOrigin
for i, v in pairs(exgfx) do
local pclone = v:Clone()
pclone.Parent = PO
pclone.Enabled = true
end
exaudio.Parent = PO
exaudio:Play()
clone.Transparency = 1
clone.CanTouch = false
clone.Anchored = true
for i, v in pairs(PO:GetDescendants()) do
if v.Name == "ParticleEmitter" then
v.Enabled = false
wait(0.05)
end
end
clone:Destroy()
return
end
Not sure, it’s probably just a little delay. I don’t really think you can do much about that. Only good thing is that it probably won’t be TOO noticeable.
Found the issue.
Since it was a server script, it was running a little too fast for the client. The bullet hit the part on the server before the bullet hit the part on the client thus making it explode in the air. All I had to do was just make it a client script. I will probably use remote function and events to make it better but for now, it works :).