In my fireball, I have the part move towards the location of the player’s mouses position using BodyVelocity. However, on the client, it explodes when it visually impacts the enemy. On the server-side, it seems to impact it early on, causing the explosion to start early.
Server Side - Left Side
Client-Side - Right Side (Person who fired the fireball)
The entire animation, with particles, is all server sided.
local Debris = game:GetService("Debris")
local debounce = false
script.Parent.FireBall.OnServerEvent:Connect(function(player,mouse)
if not debounce then
debounce = true
wait(.2)
local touchdebounce = false
newFireBall.Touched:Connect(function(part)
if part.Parent.Name == player.Name then return end
if part.Name == "FireBall" then return end
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local enemy = game.Players:GetPlayerFromCharacter(part.Parent)
if enemy.TeamColor ~= player.TeamColor then
if not touchdebounce then
touchdebounce = true
part.Parent.Humanoid:TakeDamage(12)
FireBallExplosion(newFireBall)
wait(1)
touchdebounce = false
end
end
end
end)
wait(2)
if newFireBall ~= nil then
FireBallExplosion(newFireBall)
end
debounce = false
end
end)
I took some code out of the script that would not effect it.