Hello, I'm making a self-check-in system for a hotel game and I needed to store if the room is taken or not. For this, I made a Folder with BoolValues. For some reason, the script runs at the start but does not keep testing for the BoolValue. It goes off the starting value and not the updated one, but my print keeps printing.
Here are the scrips:
(0 = not taken | 1 = taken)
while true do
if script.Parent.Value == 1 then
game.ReplicatedStorage.RoomTaken["Room 101"].Value = true
elseif script.Parent.Value == 0 then
game.ReplicatedStorage.RoomTaken["Room 101"].Value = false
wait(0.5)
end
end
while true do
if game.ReplicatedStorage.RoomTaken["Room 101"].Value == false then
script.Parent.BrickColor = BrickColor.new("Medium green")
print("Green")
elseif game.ReplicatedStorage.RoomTaken["Room 101"].Value == true then
script.Parent.BrickColor = BrickColor.new("Bright red")
print("Red")
wait(1)
end
end

6 comments
Put in CodeBox
Done.
MMmmh while true do. While TRUE do. Why are we using this? Why not watch for the value changing then call our action.
Could you give me an example?
1.) while true do is not a function. 2.) It is never a good idea to create an infinite loop with no ending condition. 3.) If there is an event that can take the place of a loop, use it (in your case that would be the Changed event). 4.) Your first if statement in both scenarios has no yield inside of it. That means if your Value does not change fast enough from 1/false, your game will crash.
Finally, your main issue is likely that your Value is not 1.) being correctly changed, or 2.) being correctly accessed.