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

How to check if Bool value changed?

Asked by 4 years ago

So I need my script to continuously check if a certain bool value changed but I don't know how. Anyone here who knows how to do this?

I tried to put it in my loop like this but that didn't work:

while game.ReplicatedStorage.RoundSystemValues.VoteStarted.Value == true do

1 answer

Log in to vote
0
Answered by 4 years ago

You can either use the instance.Changed event or put the check inside a while wait() do loop.

this is the instance.Changed() event version

game.ReplicatedStorage.RoundSystemValues.VoteStarted.Changed:Connect(function()
    if game.ReplicatedStorage.RoundSystemValues.VoteStarted.Value = true then
        --insert what you want to happen here
    else

    end
end)

this is the while wait() do loop

while wait() do
    if game.ReplicatedStorage.RoundSystemValues.VoteStarted.Value = true then
        --insert what you want to happen here
    else

    end
end

Note: i use a while wait() do loop instead of a while true do loop to avoid script exhaustion.

1
It worked, thanks a lot! :) plantenpot 5 — 4y
Ad

Answer this question