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

This bool value changing script doesn't work. Can you tell me how to fix this?

I am trying to make a script that changes a bool value inside every player to false if another bool value, which is inside the Replicated Storage is true. If that value is false then the bool value inside every player will become true, but it doesn't work. What is the problem here?

And also in the output it doesn't show anything related to this script.

Here is the script:

local repstorage = game.ReplicatedStorage
local round = repstorage.RoundInProgress.RoundInProgress
local Players = game:GetService("Players")

if round.Value == true then
	wait(0.5)
	for i,v in pairs(Players:GetChildren()) do
		v.ChangeTeam.Value = false
	end
elseif round.Value == false then
	wait(0.5)
	for i,v in pairs(Players:GetChildren()) do
		v.ChangeTeam.Value = true
	end
end

Thanks!

2 comments

0

What is the output?

0

In the output it doesn't show anything related to this script.

1 answer

✓ Accepted answer

Your script is only checking the value of "round" when the game starts. In order to check the value whenever it is changed, you should use connect a function to when "round" is changed. Here's an example.

local repstorage = game.ReplicatedStorage
local round = repstorage.RoundInProgress.RoundInProgress
local Players = game:GetService("Players")

round.Changed:Connect(function()
	if round.Value == true then
	    wait(0.5)
	    for i,v in pairs(Players:GetChildren()) do
	        v.ChangeTeam.Value = false
	    end
	elseif round.Value == false then
	    wait(0.5)
	    for i,v in pairs(Players:GetChildren()) do
	        v.ChangeTeam.Value = true
	    end
	end
end)

1 comment

0

Thanks it worked! I can't believe what a silly mistake I did!

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