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

Why is the Values Not Updateing? [Closed]

Here is my script its for a player check, PC = PlayerCheck.Value and PN = PlayerNeeded.Value. any HELP plz? also PlayerNumber = game.Players.NumPlayers

while wait(1) do
	if PC == true then
		if PlayerNumber >= 2 then
			print("PLAYERS REACHED 2+")
			PN = false
			PC = false
		elseif PlayerNumber <= 1 then
			print("PLAYERS REACHED 1")
			PN = true
			PN = true
		end
	end
end

2 answers

✓ Accepted answer

Remove the .Value from your variables, dont call value from a variable.

while wait(1) do
    if PC.Value == true then
        if PlayerNumber >= 2 then
            print("PLAYERS REACHED 2+")
            PN.Value = false
            PC.Value = false
        elseif PlayerNumber <= 1 then
            print("PLAYERS REACHED 1")
            PN.Value = true
            PN.Value = true
        end
    end
end

4 comments

0

Ok Makes sence Ill try that

0

Sorry It Did not work

0

if you manually change the playernumber value does it work?

0

I fixed It I will close it and to be honest thank you, i needed to get out of that way of making .Value and the end of every shortcut ya know?

The answer to this is make sure that there is no two while true do loops like this!

p = 1
r = 3

while p == 1 do
	while r == 3 do
		wait(0.1)
		p = p - 1
		print("Loop")
	end
end

-- Second script aka the real awnser --

Player = game.Players
PN = game.ReplicatedStorage.MainValues.PlayerNeeded
PC = game.ReplicatedStorage.MainValues.PlayerCheck
PA = game.ReplicatedStorage.Values.PlayerAmount

Player.PlayerAdded:Connect(function(Added)
	PA.Value = PA.Value + 1
end)

Player.PlayerRemoving:Connect(function(Removing)
	PA.Value = PA.Value - 1
end)

while PC.Value == true do
	wait(1)
	if PA.Value >= 2 then
		print("EnoughPlayers")
		PN.Value = false
		PC.Value = false
		print(PN.Value)
	end
end

On 0.2nd second its supposed to stop right? wrong it keeps going and doesn't bother to go back clearly because it wants to restart there it goes like simple knowledge while true do --> do something --> go back to the same while true do.

And to answer this question I needed to add value for player leave or join. I temporarly removed something cause it would loop and lag.

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