My PlayerWinning script isnt working…
The Explorer:

The Script:
local players = game:GetService(“Players”):GetPlayers()
game.ReplicatedStorage.StartingGame.GameNeedsToStart.OnServerEvent:Connect(function()
while true do
wait(0.25)
if #players == 1 then
game.ReplicatedStorage.PlayerWonGame.PlayerWon:FireAllClients(game.Workspace.DistributedGameTime)
end
end
wait(0.25)
end)
–END OF SCRIPT!–
And finally, the LocalScript on the client side:
game.ReplicatedStorage.PlayerWonGame.PlayerWon.OnClientEvent:Connect(function()
script.Parent.Frame.Visible = true
script.Parent.Frame.TextLabel.Text = "CONGRATULATIONS! YOU’VE WON ALONE IN ONLY "… time()… "! [You have been transfered 5000 Money into your account!] "
game.Players.LocalPlayer.Money.Value = game.Players.LocalPlayer.Money.Value + 5000
wait(60)
game:GetService(“TeleportService”):Teleport(3345365809,game.Players.LocalPlayer,game.Players.LocalPlayer.Money.Value, nil)
end)
–END OF SCRIPT!–
So I don’t understand why? Does anyone know how to help? it would mean the world to me. Thanks! (I’m just wanting to finish the whole gameplay aspect and this is the last part that I need to finish, of course the last part has to take forever…)
Was there an error message at all when you tested it?
Nope, just an empty output. I added print lines too and it didn’t detect any firing of the GameNeedsToStart event. There are scripts that fire that event though, si U don’t know why.
So, your script is not activated at all. And this is because the RemoteEvent isn’t fired?
If that’s the case, check the script that fires the GameNeedsToStart event.
Hey so just playing around here, I just figured out that it randomly started working, but it isn;t detecting the single player count. Not sure why… (I’ve went into a live server on my phone and PC and left on my phone, and the PC Dev Console printed “WinningScript didn’t detect a single player PlayerCount”, as it’s programmed to when more than one player remains.) Thanks for the help, by the way!
Move the players variable into loop.
The script is getting the number of players when the script is first run, and storing that number as ‘players’. It is never updating that variable. My suggestion would be to do this to the code:
local playerService = game:GetService(“Players”)
game.ReplicatedStorage.StartingGame.GameNeedsToStart.OnServerEvent:Connect(function()
while true do
wait(0.25)
if #playerService:GetPlayers() == 1 then
game.ReplicatedStorage.PlayerWonGame.PlayerWon:FireAllClients(game.Workspace.DistributedGameTime)
end
end
wait(0.25)
end)
1 Like
I understand, thanks so much! I’ll test this out, and mark it as the solution if it works. 
2 Likes
Well guess what? It, sadly… worked because it was a very smart solution. I don’t know how I didn’t see that at first! I guess scripting at 1am isn’t the greatest for focus either, though, lol. Thanks again! Have a good rest of your day!
2 Likes
Thanks you too.
Don’t worry, late night programming gets to all of us. One time I was pulling my hair out trying to figure out why my script couldn’t find an object that was clearly in my game. I had archivable disabled.
1 Like
Really?! That’s crazy, I have those moments too! Just one simple thing, like the wrong object being named, and I am stressed out! 
2 Likes