Basically, I have a fireball where when you shoot it, a remote event fires and spawns a fireball a few studs away from the player and shoots it in the direction of the player. However, if the player moves forward and shoots a fireball, then the fireball will detect it as an other player and attack the player who was shooting the fireball. How can I add a statement where if it’s the player, then it won’t detect it as an enemy?
script that happens when remote event is fired:
local clonedFireball = game.ReplicatedStorage["ball of fireball"]:Clone()
local CF = player.Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -4)
clonedFireball.Parent = workspace
clonedFireball.CFrame = CF
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = clonedFireball
BodyVelocity.Velocity = player.character.HumanoidRootPart.CFrame.lookVector * 75
clonedFireball.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not player then
hit.Parent.Humanoid:TakeDamage(10)
clonedFireball:Destroy()
end
elseif not hit.Parent:FindFirstChild("Humanoid") then
local Explosion = Instance.new("Explosion")
Explosion.Parent = workspace
Explosion.ExplosionType = Enum.ExplosionType.NoCraters
Explosion.BlastRadius = 3
Explosion.DestroyJointRadiusPercent = 0
Explosion.Position = clonedFireball.Position
clonedFireball:Destroy()
end
end)
end)