Touched damage need help

im creating a fire ball but i need a script to damage people when i shoot instead of it damaging me

local killpart = script.Parent

local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
Parent.Humanoid.Health = 0
end
end

killpart.Touched:Connect(PlayerTouched)

print(“works”)

ive tried alot of them but they hurt the user so if you know one pls let me know thank you!?

You could check in the PlayerTouched function to make sure the player returned from Players:GetPlayerFromCharacter() is not the tool owner by doing something like

local Player = game:GetService('Players'):GetPlayerFromCharacter(Parent)

if Player and Player ~= TOOLOWNER then
    return
end

Depending on if the kill part is a descendant of the tool, you could grab the toolowner by doing Players:GetPlayerFromCharacter(script:FindFirstAncestorOfClass('Tool').Parent) to grab the player who currently has the tool equipped

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.