Hold on, I thought we are checking the players “Playing” BoolValue in here, also I don’t see the code that is handling the IntValue other than the .PlayerCount.Value what are you doing to add a player or remove one?
if so then why are we checking the TouchedStart value instead? Any explanation what is TouchedStart currently I don’t see it anywhere else in the code?
BTW, for creating an Instance like you did with:
local playing = Instance.new("BoolValue", player)
it’s good practice to not have a second parent argument due to how Roblox events works in this tutorial:
also for code formatting, I recommend separating the functions like so just to make the addPlayer function less lengthy.
--lots of other values that for the player that I deleted to be concise
--remove character funciton that removes active players when they die or leave
local function removeCharacter(player)
if(player.Playing.Value == true) then
--lots of other code for the main part of the game.....bla bla bla bla
end
if player.TouchedStart.Value == true then
game.Workspace.SpawnBase.Barracks["Start Training"].PlayerCount.Value = game.Workspace.SpawnBase.Barracks["Start Training"].PlayerCount.Value - 1
player.TouchedStart.Value = false
end
end
function addPlayer(player)
local playing = Instance.new("BoolValue", player)
playing.Value = false
playing.Name = "Playing"
player.CharacterRemoving:Connect(removeCharacter(player))
end
game:GetService("Players").PlayerAdded:Connect(addPlayer)