ur code is so unnecessary its way easier to do this
make another script in the same part and name it GiveDamage
in the original script u do
debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent:FindFirstChild("GiveDamage") then
script.Parent.GiveDamage.Parent = script.Parent
elseif not hit.Parent:FindFirstChild("GiveDamage") then
if not debounce then
debounce = true
script.Parent.GiveDamage:Clone().Parent = hit.Parent
print("script given")
wait(2)
debounce = false
end
end
end
end)
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Health.Disabled = true
end
end)
in the give damage script u do
while true do
wait(1)
if script.Parent:FindFirstChild("Humanoid") then
script.Parent.Humanoid.Health = script.Parent.Humanoid.Health - 2
print("lost health")
end
end
i pulled this from my own game where i have pretty much the same thing
1 comment
loop it