Detected value is false even it is true

Hello developers, I tried to make a wait function that yields until a value is true and it doesn’t work.

Module Code:

local serverStarted = false

function KoolServer:Start()

        serverStarted = true

end

function KoolClient:WaitForServer()
		
       --prints false
		repeat RunService.Heartbeat:Wait() print(serverStarted) until serverStarted == true

end

Code:

Client:
Kool:WaitForServer()
print(134567) --does not print

Server:
Kool:Start()

Any help is appreciated, thanks.

Thanks for the reply. Sadly, it didn’t work, the serverStarted is still false.

Make the value a BoolValue instance. Your variable is exclusive for every script that requires the module script, that’s why it cant detect it.

1 Like

Thanks it worked! fjhjhfjhfsdkjjfhsdf30chars