game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function()
local GameValue = Instance.new("BoolValue")
GameValue.Parent = Player.Character
GameValue.Name = "InGameValue"
end)
end)
function CheckPlayers()
local InGameNum = 0
for _,v in pairs(game.Players:GetChildren())do
local Character = v.Character
if Character then
local InGameValue = Character:FindFirstChild("InGameValue")
if InGameValue and InGameValue == true then
InGameNum = InGameNum + 1
else
print(Player.."'s InGameValue not found")
end
else
print(Player.."'s Character not found")
end
end
if InGameNum == 0 then
return false
elseif InGameNum ~= 0 then
return true
else
return nil
end
end
function roundCountdown()
for roundMinute = 2,0,-1 do
for roundSecond = 59,0,-1 do
playerNotification('Time left!')
playerCountdown(string.format("%d:%.2d",roundMinute,roundSecond))
local CheckInGame = CheckPlayers()
if CheckInGame == false then
roundSecond = 0
elseif CheckInGame == true then
print("There are still people in the game")
end
wait(1)
end
end
end
This code goes after you teleport the players:
local PlayerInGameValue = player.Character.FindFirstChild("InGameValue")
if PlayerInGameValue then
PlayerInGameValue.Value = true
else
print("Can not find: 'InGameValue'")
end
This should work, it does require you to set the value of "InGameValue" located in the player's character to true when you place him in a round though.
4 comments
It doesn't seem to work at all. It just skips to the end of the round once it round even starts. I was wondering how I could use it with IntValues. For example, if everybody's 'Playing' value is equal to zero then it ends the round.
Just edited it, It should work now. Remember to set the value of "InGameValue" to true when the players enter a round/minigame.
Still not working, it does the same thing as before.
Did you set the "InGameValue" to true when the players entered a round?