So basically I want to stop the health regeneration of a player when they touch Part A but only continue healing after touching Part B. I tried doing the opposite of the health script by removing a health point per second. However, they script only minus the health of a player like 5 times because I have not added a debounce yet cause I am afraid multiple players land on it at once and some would evade the stopping for health regeneration. I have tried looking devforum about this but only found posts regarding the delaying of health regeneration so far. Of course I am not asking you to write the entire script for me but tell me what I should use to achieve my goal
The script:
script.Parent.Touched:Connect(function(hit)
local tb = 0
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
tb = 1
while tb == 1 do
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 1
wait(1)
if game.Workspace.NoRegenLand.RestartRegen and hit.Parent:FindFirstChild("Humanoid") then
tb = 0
break
end
end
end
end)
But where do I put the script under as I want regeneration to comeback if the player touches another part or dies. Also the health script is under a model in studios
local Players = game:GetService('Players')
local Part = script.Parent
Part.Touched:Connect(function(hit)
local Player = Players:GetPlayerFromCharacter(hit.Parent)
if Player then
local Character = Player.Character
if Character then
local Health = Character:FindFirstChild('Health')
if Health then
-- disable / enable.
end
end
end
end)