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

This boolean value change detector script doesn't work. What is the problem with my script?

I am making a script which will check if a BoolValue is true or false. I have tried making the script, but it is not working. It shows an error in the output too.

Here is the script:

local remote = game.ReplicatedStorage:WaitForChild("SimonSaysEditor", 100)
local start = game.ReplicatedStorage.Values.StartRound
local inter = game.ReplicatedStorage.Values.Intermission

function startChanged()
	if start.Value == true then
		wait(1)
		start = false
		local simon = game.Players:GetPlayers()[math.random(1,#game.Players:GetPlayers())]
		remote:FireAllClients("The simon for this game is going to be " .. simon.Name .. "!")
		wait(3)
		remote:FireAllClients("", false)
		simon.Team = game.Teams.Simon
		wait(0.5)
		simon:LoadCharacter()
		local spectate = game.Teams.Spectators:GetPlayers()
		wait(0.5)
		for i,v in pairs(spectate) do
			v.Team = game.Teams.Players
			v:LoadCharacter()
		end
		wait()
		inter.Value = true
	end
end

start:GetPropertyChangedSignal("Value"):Connect(startChanged

Start is a Boolean value in Replicated Storage.

It shows this error in the output:

00:23:19.250 - ServerScriptService.StartRound:7: attempt to index upvalue 'start' (a boolean value)

The script works the first time but doesn't work 2nd time.

Please tell me how I can solve this problem. I have tried a lot but I am unable to make it work.

8 comments

0

Please post the full code. You never show where start is declared.

0

Done.

0

Why are you saying start["Value"].Value?

0

I have tried changing it to that but it is not working too.

0

I saw it on roblox developer forum.

0

And also the script works the first time but on the second time it doesn't work.

0

Please tell me what is the problem. Please.

0

All value objects have a Changed event do not use GetPropertyChangedSignal.

1 answer

Your issue is on line 8 of the script you provided, where it changes start from an Object to a Boolean

Instead of

start = false

You'll want to do

start.Value = false;

What you are doing is changing start from a saved BoolValue object to a boolean variable, and when you try to get the value of this it errors.

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