I'm making an advanced game and everything is ok apart from this script. The number called game.ReplicatedStorage.Values.PlayerCount is not increasing in the script, so the game is instantly starting. How do I fix it? This is the code I tried:

game.Players.PlayerAdded:Connect(function(plr)
	game.ReplicatedStorage.Values.PlayerCount.Value = game.ReplicatedStorage.Values.PlayerCount.Value +1
	script.Parent.Parent.PlayerStats["Player"..game.ReplicatedStorage.Values.PlayerCount.Value].PlayerName.Text = plr.Name
	script.Parent.Parent.PlayerStats["Player"..game.ReplicatedStorage.Values.PlayerCount.Value].Name = plr.Name
	
	local plrStats = Instance.new("Folder")
	plrStats.Name = plr.Name
	plrStats.Parent = game.ReplicatedStorage.PlayerAssets
	
	local plrInventory = Instance.new("Folder")
	plrInventory.Name = "Inventory"
	plrInventory.Parent = game.ReplicatedStorage.PlayerAssets[plr.Name]
	
	script.Parent.MouseButton1Click:Connect(function()
		script.Parent.Parent.PlayerStats[plr.Name].BackgroundColor3 = Color3.fromRGB(0, 255, 0)
		script.Parent.Parent.PlayerStats[plr.Name].PlayerStatus.Text = "Ready"
		game.ReplicatedStorage.Values.PlayersReady.Value = game.ReplicatedStorage.Values.PlayersReady.Value +1
		script.Parent.Visible = false
	end)
end)

Bit of help, please! Thanks!

5 comments

0

what kind of script is it in

0

Server Script (Regular Script)

0

odd, try moving line 2 to line 18 instead

0

That wouldn't work

0

Is the output giving you anything? Try waiting for the PlayerCount value to load in before doing anything with it.