I made a door script and a text label script with a cooldown. I wan’t both of the scripts to be seperate and that’s how I have them. What I wan’t is the cooldown to decrease faster when the door is closed, but the issue is that I don’t know how to. My first idea was to somehow check in the text label script a debounce value that I have inside the door script, but searching on devforum didn’t help me. My second idea was to use the door’s position but that’s unreliable and didn’t work either. How will I be able to do something like that?
Textlabel script
local text = script.Parent
local countdown = 100
for count = -1, 100, 10 do
countdown -= 1
text.Text = countdown
wait(1)
end
I think what you should do is to either place a BoolValue or a boolean attribute in the door that changes depending on the door’s state (true if the door is closed, false if the door is open)
Then in your countdown script, check the state of that boolean, if it’s true, make it wait a shorter time, if it’s false, use 1 second as you currently do
Example
if door:GetAttribute("IsClosed") then
task.wait(0.5) -- Something less than than the open time
else
task.wait(1)
end
No scripting required either, go into the explorer and from there add a BoolValue (or go into the properties of the door and create a new attribute if that’s what you prefer)
Then in your door code, when the door opens or closes, change the state of the boolean
Yes, in both your door code and your countdown code t here should be a variable that references the boolean itself so you can use it to change its state or check its state