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

How do I make a local script know when a boolean in the ReplicatedStorage == true?

--The text displays as the intermission() when the boolean GameInProgress == true. There are no syntax errors so I don't know what's wrong. local seconds = game.ReplicatedStorage.Time

script.Parent.Text = "Loading"

game.ReplicatedStorage:WaitForChild("GameInProgress")

if game.ReplicatedStorage.GameInProgress == true then

script.Parent.Text = game.ReplicatedStorage.MapName.Value.." ("..seconds.Value..")"

else

script.Parent.Text = "Intermission ("..seconds.Value..")"

end

1 comment

0

Another thing before anyone asks. No people are not able to change the value locally.

1 answer

✓ Accepted answer

Check the Value of GameInProgress.

What you are doing right now is simply checking if the object itself equals true, which will never be true.

You meant to check the value of GameInProgress.

local ReplicatedStorage = game:GetService("ReplicatedStorage");
local seconds = ReplicatedStorage.Time;
local inProgress = ReplicatedStorage.GameInProgress;
local mapName = ReplicatedStorage.MapName;
local label = script.Parent;

label.Text = string.format("%s (%d)", inProgress.Value and mapName.Value or "Intermission", seconds.Value);

where is ternary operator eeeee

"%s" is a string in string.format, "%d" is a digit.

%s is whitespace everywhere else but string.format


There are no syntax errors so I don’t know what’s wrong.

Syntax errors aren't the only reason programs don't work.

There are runtime errors, errors that occur whilst your code is running, and logic errors, which aren't actual errors, but flaws with your code structure.

1 comment

1

ikr

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