Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to check if Bool value changed?

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

✓ Accepted answer

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 comment

1

It worked, thanks a lot! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.