The reason your temp value goes up super sonic is because Touched events register every single touch, without a cooldown, and that's where you should add a cooldown/ debounce.
Your script but with a debounce:
02 | local plr = game.Players.LocalPlayer |
03 | local Char = plr.Character |
04 | local Hot = game.Workspace.Temps.Hot |
05 | local Cold = game.Workspace.Temps.Cold |
06 | local Temp = script.Parent.Parent.Temp |
08 | local temperature = { Hot,Cold } |
17 | game.Players.LocalPlayer:WaitForChild( "Temp" ) |
19 | Hot.Touched:Connect( function (hit) |
20 | if hit and hit.Parent and hit.Parent:FindFirstChild( "Humanoid" ) and not debounce then |
24 | game.Players.LocalPlayer.Temp.Value = Temp.Value + 1 |
34 | game.Players.LocalPlayer:WaitForChild( "Temp" ) |
36 | Cold.Touched:Connect( function (hit) |
37 | if hit and hit.Parent and hit.Parent:FindFirstChild( "Humanoid" ) and not debounce then |
41 | game.Players.LocalPlayer.Temp.Value = Temp.Value - 1 |
53 | local k = Instance.new( "Sound" ) |
55 | if game.Players.LocalPlayer.Temp.Value < - 400 then |
56 | local children = Char:GetChildren() |
57 | for i = 1 , #children do |
58 | local child = children [ i ] |
59 | if children:IsA( "BasePart" ) or children:IsA( "MeshPart" ) then |
60 | children.Anchored = true |
61 | if children:IsA( "BodyColors" ) then |
62 | HeadColor 3 = Color 3. fromRGB( 34 , 165 , 205 ) |
63 | LeftArmColor 3 = Color 3. fromRGB( 34 , 165 , 205 ) |
64 | LeftLegColor 3 = Color 3. fromRGB( 34 , 165 , 205 ) |
65 | HeadColor 3 = Color 3. fromRGB( 34 , 165 , 205 ) |
66 | RightArmColor 3 = Color 3. fromRGB( 34 , 165 , 205 ) |
67 | RightLegColor 3 = Color 3. fromRGB( 34 , 165 , 205 ) |
68 | TorsoColor 3 = Color 3. fromRGB( 34 , 165 , 205 ) |
71 | if children:IsA( "Decal" ) then |
76 | Char.Humanoid.Health = 0 |
77 | Char.Humanoid.MaxHealth = 0 |