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

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

Asked by 5 years ago
Edited 5 years ago

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!

0
What is the output? Rheines 661 — 5y
0
In the output it doesn't show anything related to this script. StrategicPlayZ 58 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
0
Thanks it worked! I can't believe what a silly mistake I did! StrategicPlayZ 58 — 5y
Ad

Answer this question