Hello! I’m working on the temperature events like if you touch a hot area, it will increase your temperature repeatedly. Now my issue with speed is that if you touched many zones, it will add more speed. Let me show you, here’s the link for the video Gyazo Video This is a normal speed. Now here’s the issue video Gyazo Video 2
My script in StarterCharacterScripts
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local folder = character:WaitForChild("TemperatureValues")
repeat task.wait() until folder
local temp = folder.Temperature
local HWC = folder.HWC
local speed = folder.Speed
HWC:GetPropertyChangedSignal("Value"):Connect(function()
if HWC.Value == "Warm" then
while true do
if HWC.Value == "Warm" then
if temp.Value ~= 15 then
if temp.Value >= 15 then
temp.Value = temp.Value - 1
elseif temp.Value <= 15 then
temp.Value = temp.Value + 1
end
end
else
break
end
task.wait(speed.Value)
end
elseif HWC.Value == "Cold" then
while true do
if HWC.Value == "Cold" then
if temp.Value >= 0 then
temp.Value = temp.Value - 1
if temp.Value == 0 or temp.Value <= 0 then
humanoid:TakeDamage(humanoid.MaxHealth)
end
end
else
break
end
task.wait(speed.Value)
end
elseif HWC.Value == "Hot" then
while true do
if HWC.Value == "Hot" then
if temp.Value <= 30 then
temp.Value = temp.Value + 1
if temp.Value == 30 or temp.Value >= 30 then
humanoid:TakeDamage(humanoid.MaxHealth)
end
end
else
break
end
task.wait(speed.Value)
end
end
end)
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local folder = character:WaitForChild("TemperatureValues")
repeat task.wait() until folder
local temp = folder.Temperature
local HWC = folder.HWC
local speed = folder.Speed
local function increase()
if temp.Value <= 30 then
temp.Value = temp.Value + 1
if temp.Value == 30 or temp.Value >= 30 then
humanoid:TakeDamage(humanoid.MaxHealth)
end
end
end
local function decrease()
if temp.Value >= 0 then
temp.Value = temp.Value - 1
if temp.Value == 0 or temp.Value <= 0 then
humanoid:TakeDamage(humanoid.MaxHealth)
end
end
end
local function goalwarmtemp()
if temp.Value ~= 15 then
if temp.Value >= 15 then
temp.Value = temp.Value - 1
elseif temp.Value <= 15 then
temp.Value = temp.Value + 1
end
end
end
while true do
if HWC.Value == "Warm" then
goalwarmtemp()
elseif HWC.Value == "Cold" then
decrease()
elseif HWC.Value == "Hot" then
increase()
end
task.wait(speed.Value)
end