I am trying to make a script where you lose body tempreature over time, and once you get to 93 body tempreature you start to die. You can also get body tempreature back by standing next to a campfire, which I called heatArea. Something is very messed up with it though, because when you go in the heatArea, it goes up in heat way more than it should, and you can go in and out of the heatArea to get very warm. Also sometimes you will start dying out of nowhere even if you are not at 93 body tempreature. I also don’t know how to make it so that you can only go up to 100 body tempreature. Please help.
local temp = 98.6
local counter = 93
local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local heatArea = game.Workspace.Campfire.Heat
local sound = player.PlayerGui:FindFirstChild("Freezing")
local GUIText = game.ReplicatedStorage:WaitForChild("GUIText")
local function heat()
wait(3)
temp = temp + 0.5
counter = counter + 0.5
end
while true do
GUIText.Value = temp
wait(5)
temp = temp - 0.5
if temp <= counter then
humanoid.Health = humanoid.Health - (humanoid.MaxHealth/4)
counter = counter-1
sound:Play()
else
heatArea.Touched:Connect(heat)
end
end