i want to have a part that does damage on any humanoid except the owner of the part,
i did make a part appear with script in it and value in it, so owner name is always will be in the value that in the part, the problem im having is my script is not doing damage to other humanoids right now,
local part = script.Parent
local debounce = false
part.Touched:Connect(function(hit)
local owner = script.Parent:FindFirstChildOfClass("IntValue")
local human = hit.Parent:FindFirstChild("Humanoid")
if human and debounce == false and not hit.Parent.Name == owner.Name then
human.Health = human.Health - 10
debounce = true
end
end)
if i understood you correctly, there is the script
local part = script.Parent
local debounce = false
part.Touched:Connect(function(hit)
local owner = script.Parent:FindFirstChildOfClass("StringValue") --- Set value to owner's name
local human = hit.Parent:FindFirstChild("Humanoid")
if human and debounce == false and hit:FindFirstAncestorWhichIsA("Model").Name ~= owner.Value then
debounce = true
human.Health = human.Health - 10
end
end)
I replaced the IntValue with a StringValue. You may not want that, but the rest of the script works now:
local part = script.Parent
local debounce = true
part.Touched:Connect(function(hit)
local owner = script.Parent:FindFirstChildOfClass("StringValue")
local human = hit.Parent:FindFirstChild("Humanoid")
if human and debounce and hit.Parent.Name ~= owner.Value then
print("Part Stepped On By", hit.Parent)
debounce = false
human.Health = human.Health - 10
task.wait(1) -- however long you want to wait before pad can be touched again
debounce = true
end
end)
Well the way you check for the owner confuses me a little bit.
Is the IntValues name, the name of the owner? I would recommend to use an ObjectValue or a StringValue and use the actual value property and not the name.
Other then that you should check that the humanoid that is hit isn’t already dead (so HP 0 or below) and your script should be fine I guess.
That script doesn’t make sense, you always set the debounce to true which basically doesn’t fullfill it’s purpose as it’s only supposed to damage once when I understood @hayaliso correctly.