Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my temperature script so buggy when i step into the part?

Asked by
iuclds 720 Moderation Voter
5 years ago

it literally goes sonic speed then slows down like I'm confused.

01wait(1)
02local plr = game.Players.LocalPlayer
03local Char = plr.Character
04local Hot = game.Workspace.Temps.Hot
05local Cold = game.Workspace.Temps.Cold
06local Temp = script.Parent.Parent.Temp
07 
08local temperature = {Hot,Cold}
09 
10 
11wait(1)
12-- // Hot x Cold \\ --
13 
14 
15game.Players.LocalPlayer:WaitForChild("Temp")
View all 82 lines...

1 answer

Log in to vote
1
Answered by
bluzorro 417 Moderation Voter
5 years ago

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:

01wait(1)
02local plr = game.Players.LocalPlayer
03local Char = plr.Character
04local Hot = game.Workspace.Temps.Hot
05local Cold = game.Workspace.Temps.Cold
06local Temp = script.Parent.Parent.Temp
07 
08local temperature = {Hot,Cold}
09 
10local debounce = false
11 
12 
13wait(1)
14-- // Hot x Cold \\ --
15 
View all 88 lines...
Ad

Answer this question