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

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

Asked by 5 years ago

--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

0
Another thing before anyone asks. No people are not able to change the value locally. ReallyUnikatni 68 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

```lua 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
ikr danglt 185 — 5y
Ad

Answer this question