In my game that I am creating, I require a part to damage the player once every second, not once everytime the player touched the part.
Here is my attempt:
local function PlayerTouched(Part)
local Parent = Part.Parent
if game.Players:GetPlayerFromCharacter(Parent) then
if script.Parent:FindFirstChild("Fire") then
Parent.Humanoid.Health = Parent.Humanoid.Health - 4
wait(1)
else
end
end
end
script.Parent.Touched:Connect(PlayerTouched)
This script damages the player, but it pretty much instantly kills the player. I am guessing it is doing this because the script is fired every time the player touches the fire.
How would edit this script to make the player take damage once every second?
