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

how do I end the endless suffering of this repeat?

Asked by 4 years ago
local rep = game:GetService(“ReplicatedStorage”)
local playingCount = rep:WaitForChild(“playingCount”)
local Status = rep:WaitForChild(“Status”)

while true do
    Status.Value = “waiting...”

    repeat wait(1) until playingCount.Value > 0

    Status.Value = “starting...”
end

playingCount is an intValue in replicatedstorage. I have it so that the click of a GUI button will increase playingCount by 1. I checked the value manually, it does increase. but the “repeat wait(1) until ...” never stops waiting(1).

to test it out, i did this:

repeat print(playingCount.Value) wait(1) until playingCount.Value > 0

and despite the value actually being 1, the script variable remains 0

how fix? need 2 fix. am not know how fix. thx

0
The code is always going to repeat until playingCount.Value is greater than 0. By the way, wrong quotes. raid6n 2196 — 4y
0
playingCount.Value is greater than 0. I manually change it in the inspector thing Spiritlotus 151 — 4y
0
Do you change the value in this code or another code? raid6n 2196 — 4y
0
i change the value of the intValue in another code. but playingCount is the reference of the value I change Spiritlotus 151 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

If this is in a Server Script, you will need to use Remote Events. Changes made by the client aren't replicated to the server, therefore if you change it in the explorer or have a local script change the value, the Server won't know. You can add a remote event in Replicated Storage. When you click a button, the remote event will :FireServer(), then have a Server Script wait for the event to fire, then do the actions.Also I do not recommend putting a repeat until inside of while true do. The while true do is useless here becuase I'm assumming this code will only run until the value is bigger than 0.

0
havnt tried this yet (i will later) but it sounds correct so ill accept lol. thank you very much, forgot about needing to do that. also im tryna make a minigame that repeats so thats what the while loop is for Spiritlotus 151 — 4y
Ad

Answer this question