Hello. I want to make it so that every second after you click a part, you take 1 damage. Right now it just instant kills me and idk why. Can someone help please!
local count = 0
local cooldown = 0
script.Parent.TeleportPart1.Transparency = 1
script.Parent.TeleportPart2.Transparency = 1
script.Parent.Door.ClickDetector.MouseClick:Connect(function(plr)
if count == 0 and cooldown == 0 then
cooldown = 1
script.Parent.Sound:Play()
game.ReplicatedStorage.Teleport:FireClient(plr)
task.wait(0.5)
local hrp = plr.Character:FindFirstChild("HumanoidRootPart")
hrp.CFrame = script.Parent.TeleportPart2.CFrame
for i = 1, 100, 1 do
task.wait(1)
local healthvalue = 100-i
plr.Character:FindFirstChild('Humanoid'):TakeDamage(healthvalue)
end
count = 1
task.wait(1)
cooldown = 0
end
end)