✓ Accepted answer
local state = values.State.Value
The variable state is storing the value of the values.State BoolValue, so changing the variable state does not change the .Value property of the values.State BoolValue.
What you should instead do is set values.State.Value to whatever value whenever you want to change it like so:
local state = values.State
state.Value = true
state is now the values.State BoolValue object, so you can set its .Value property to true by doing state.Value = true
Here's what your code should look like:
local values = game.ReplicatedStorage.Values
local state = values.State
while state.Value == false do
wait(math.random(500, 1000))
state.Value = true
end
while state.Value == true do
wait(math.random(300, 600))
state.Value = false
end
One thing to note is that wait(x) waits x amount of seconds, so wait(math.random(500, 1000)) will wait randomly between 500 to 1000 seconds, or in other words 8.33 minutes to 16.66 minutes. You should set the wait time to a lower amount, like 5 seconds, to test things out.