Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make fireball not hurt the user?

I made a fireball script and it launches out a part thats stored in Lighting. My script can damage other players using the script.Parent.Touched function but it also hurts me too if I touch it. How do I make it so that if I touch it, it won't hurt me, but if another player touches it it hurts them.

Im not gonna try and make the part spawn more ahead of me because it is a slow move that deals heavy damage.

2 answers

✓ Accepted answer

if the localplayers name is equivalent to the hits name then cancel it.

local fireball = script.Parent
local Player = game.Players.LocalPlayer

fireball.Touched:Connect(function(hit)
       if hit.Parent:FindFirstChild("Humanoid") then
        local Humanoid = hit.Parent.Humanoid

if hit.Parent.Name == Player.Name then
       -- if the player hits themself do
else
       Humanoid:TakeDamage(20)
        end
end
end)

You could name the fireball after the player's name and in the touched function if it hit the person who made it it won't hurt them.

This discussion is preserved as it was. New answers, comments, and votes are closed.