#check if there is known in a team and doing an action if there ae no players in the team
1 messages · Page 1 of 1 (latest)
Humanoid.Died
#game.Teams.[team].GetPlayers()
Then how do I do an action of its 0 sorry XD 😅
** You are now Level 8! **
do an if check
if #game.teams.team:getplayers() == 0 then
O thx I was busy so I still haven’t even even try yet and I still won’t be able to try this one like a little bit, but thank you so much
@nimble crystal im confused
local Players = game:GetService("Players");
local Teams = game:GetService("Teams");
local function AlivePlayers()
return #Teams.Alive:GetPlayers();
end
local aliveCount = AlivePlayers();
if aliveCount <= 0 then
print("No players are alive");
else
print(aliveCount.." players are still alive.");
end```
** You are now Level 2! **
where do i put the team it must check?
@devout crystal
change the Alive in AlivePlayers() to ur team's name
O ok
Is that the only thing cause it was one thing I already changed and I don’t know if I should unchain that she is that the only thing I was supposed to change from the original code or?
show code
local Players = game:GetService("Players");
local Teams = game:GetService("Teams");
local function AlivePlayers()
return #Teams.Survivors:GetPlayers();
end
local aliveCount = AlivePlayers();
if aliveCount <= 0 then
player.Team = Teams.Spectators
else
print(aliveCount.." players are still alive.");
end
just this code or the full code?
yea that should work
but it wont change the players team to spectator if thats a local script
u need to send a remote to server
and then change plr team
so the only thing i must chang is the action?
and move the corint action to a difrent scrept and replas tomtheng els in its oreganule spot?
??
can you help?
yes
ur code should work
but it wont change the players team to a spectator team if its a local script
u have to send a remote to the server and then change the players team on the server
so how do i send a remote?
create a remote event
nvm
yes
Kk
whait but that code is alredy inthe server script
@ocean badger ?
it is in the server scripted tho

?
I don't get you response
Wdym
😭
@elder heath wdym XX
i have nothing constructive to add
why did you reply with a dog eating popcorn XX
or did you want some actual help instead of... well
what this devolves into when people spoonfeed. not like you asked for that
because basically you just loop through all players in the team and check if their humanoid is alive (not in dead state, hp above 0 etc), then you can either just count how many alive players there are in the team, or use this to construct another table of only alive or only dead players who are in that team. lots of other stuff you can do too, like if a player should be kicked from their team into spectator when they die, you can connect to their humanoid died. a lot of the work here is keeping track of all the teams, where the players are, and connecting to each of their humanoids. can be a bit tricky if you're a beginner, so what stage you think you'd be at? ..... or you can wait for someone to come back in here to continue spoonfeeding up to you 
im doing it bast on if there are any players lef in a team it will end the round
i alred send evry player that dies to the spectater team
but the ramaining or the other living team is the isue so i neet to chech if a team is empte
you mean if the last living player on a team leaves? for example
baist on what i said what grateak do you have for me
no there are 2 teams serviver and corupters but if there is nun on one team it ends round and sets the players on the other team to spectater aswell
well if you do that, you can just check the remaining number of players in the team. depends a lil on when you do it. if you check remaining team members before kicking the dead player to spectator, then if the team count is 1 you know it is the last player. if you check the remaining team members after kicking the dead player, then the team count will be 0 if its the last player.
logical deductions and inferences like this is how you formulate a script
did you see this
also what tipe of cript needs this code becus i am confus cus someone sead it was in the rong script and needed to be in the server script but it was as faar as im awer in the server script
also whatt dus dis mean @elder heath
the details are your job 
i can tell you what you could do, but i won't tell you what you should do.
o ok
ya just ignore them and stick to what you already wrote for yourself in the first place.
spoonfeeding is really bad for the person being spoonfed
like you almost may as well just use ai at that point, it's the same level of taught helplessness
extremely short term benefit yes, but with detrimental long term cost.
they said the problem was it was in the rong one but told me to put it in the one it was alredy in
it's like you can have $1 today, or $100 in 10 days. the choice is obvious, but if you're desperate for that $1 you may be blinded to the $100
ya fair\
yeah, they told you what to put in. this is spoonfeeding.
it is very bad for you
(i'm aware this isn't obvious)
im just confused abut why they said it was rond then prosedid to tell me to put it were it was
tbh just remove their code entirely and go back to what you had before you put in their code
so im confued now and dont know if im rong or not
ya neither of them knew what was going on, they just prompted ai to generate some code for you and didn't think a single thought further into it
and now you're left begging "where do i put that" and "what do i do now", it's incredibly harmful to new developers
why are they helping people if they dont know 
fair
so trust me when i say, if you want to actually be a scripter, i suggest you discard the code they gave you and come up with your own code, even if that code is bad -- it's far, far more important that you understand what your code is doing, even if it's done wrong, compared to doing it right the first time.
no one ever does it right the first time. that's a natural part in learning. accept the mistakes you will make.
and you will make many.
no expert in any field is an exception to this.
clout, and to go 'hey look, im helpful!' even though you aren't even a single step closer to solving your scripting problem.
sometimes the spoonfeed is correct the first time, but even if it were, you'd only be back tomorrow because you never earned the knowledge and understanding you should have gained from solving this problem yourself, and understanding how these things work
it's like if you went to play bloxfruits, and all you did was follow around someone who is max level and they did all the work, and then they left and you never saw them again, you would have no idea how to play bloxfruits, you'd pretty much have to start from the beginning again. that's what i mean.
so.
from the beginning; show the code you already have.
without their additions
fair\
like past it hart to show you or?
paste it here, yes. if it's too long, attach as text.
-# this should have been the first thing anyone asked of you
i forggot how to do the cool thing to cover it and make it ezyer to read
like how he coverd this
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CoreEvent = ReplicatedStorage:WaitForChild("CoreEvent")
local RoundTimer = ReplicatedStorage:WaitForChild("RoundTimer")
local RoundStarted = false
local Break = false
local Corrupter
local intermissionTime =45 --in seconds
local RoundTime =180 --in seconds
local function Countdown(time)
RoundTimer.Value = time
for i = time, 0, -1 do
RoundTimer.Value = i
if #Players:GetPlayers() < 2 then
CoreEvent:FireAllClients("Round", "Clear")
Break = true
return
end
task.wait(1)
end
end
local function StartRound()
RoundStarted = true
CoreEvent:FireAllClients("Round", "Start")
Countdown(intermissionTime)
if Break then
Break = false
return
end
local players = Players:GetPlayers()
Corrupter = players[math.random(1, #players)]
Corrupter.Team = Teams.Corrupter
Corrupter.Character:PivotTo(workspace.CorrupterSpawn.CFrame + Vector3.new(0,1,0))
for _, player in ipairs(players) do
if player ~= Corrupter then
player.Team = Teams.Survivors
player.Character:PivotTo(workspace.SurvivorsSpawn.CFrame + Vector3.new(0,1,0))
end
end
CoreEvent:FireAllClients("Round", "In Progress")
Countdown(RoundTime)
StartRound()
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
player.Team = Teams.Spectators
end)
end)
if not RoundStarted and #Players:GetPlayers() > 1 then
StartRound()
end
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
player.Team = Teams.Spectators
end)
end)
end)
local Players = game:GetService("Players");
local Teams = game:GetService("Teams");
local function AlivePlayers()
return #Teams.Survivors:GetPlayers();
end
local aliveCount = AlivePlayers();
if aliveCount <= 0 then
player.Team = Teams.Spectators
else
print(aliveCount.." players are still alive.");
end
@elder heath hear
thats for the server script
formatting first
paste the whole script in one message
but you should only use that for short snippets. whole scripts -> upload as file. for simplicity.
like this
can you do that?
looks like you still have their code at the bottom, and 2 connections to game.players.playeradded for some reason?
o
i removed it
show new code? just so we're starting from page one
** You are now Level 9! **
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
player.Team = Teams.Spectators
end)
end)
if not RoundStarted and #Players:GetPlayers() > 1 then
StartRound()
end
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
player.Team = Teams.Spectators
end)
end)
end)``` what is this
you'll need to sort that out before you can do anything else
hi @elder heath
i did a youtoob how to code cors thing and i think ive lernt some of the basikes but
im still lerning
alto is is still not going perfictly smoothly
ii were i dident ven toch that scrip becus i was doing somthing in another and it stopt working
then i realisd iwas going to delat that anyway becus i did not want it
and now im stuck on watever this is but i will opfuly figer it out