basically if the player goes into the abilities area of damage they also take damage how am i able to prevent the player from damaging themselves without become invincible?
this is the script that i use to create the damage:
wait(1) function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then h.Health = h.Health -2 --Change that number to the ammount of Health you want to decrease end end script.Parent.Touched:connect(onTouched)
Try using ObjectValues
The only problem I'm seeing is with the script you posted with the question.
You can't find the player, maybe try asking the server script(the one that gets the remote) for the player.
My guess is that one of the clones contain the script, you'll need to add a ObjectValue and set the property "Value" to the player.
wait(1) local ObjectValue=script.LocalPlayer local Damage=2 function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil then if game:GetService("Players"):GetPlayerFromCharacter(part.Parent)~=ObjectValue.Value then h.Health = h.Health - Damage end end end script.Parent.Touched:connect(onTouched)
if it is a local script you can:
local plyr = game.Players.LocalPlayer wait(1) function onTouched(part) local h = part.Parent:FindFirstChild("Humanoid") if h~=nil then if h ~= plyr.Character.Humanoid then h.Health = h.Health -2 --Change that number to the ammount of Health you want to decrease end end end script.Parent.Touched:Connect(onTouched)
If it is a server script then you have to upload all your script
try this script
local lplr = game.Players.LocalPlayer function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if h~=nil and h ~= lprl then --if h isnt nil and if h isnt = local player then h.Health = h.Health -2 end end script.Parent.Touched:connect(onTouched)