Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script to get players in a team not working?

Asked by 8 years ago

Alright, so I am trying to write a script that detects when a player joins a team. In this case, the team is called 'Clocktower'. There is a NumberValue that I stuck in there so that when a player joins that team, it adds 1 to that value. Then it would initiate the bottom part of the script. Where once it detects that a player has joined that team, it would start the repeat function until there are no more people in that team. Then, it would set the health of a humanoid in workspace to 0. I am uncertain if I can use the PlayerAdded function for teams or if I am using it correctly at all. If there is an easier way to do this, please do no hesitate. Go easy on me, I am still a beginner level scripter and I am only just learning some of the more advanced 'keywords.'

game.Teams.Clocktower.PlayerAdded:connect(function(player)
    game.Teams.Clocktower.NumberValue.Value = game.Teams.Clocktower.NumberValue.Value + 1

end)

game.Teams.Clocktower.PlayerRemoved:connect(function(player)
    game.Teams.Clocktower.NumberValue.Value = game.Teams.Clocktower.NumberValue.Value - 1

end)

if game.Teams.Clocktower.NumberValue.Value == 1 then
    repeat
        wait(1)
    until game.Teams.Clocktower.NumberValue.Value == 0
    if game.Teams.Clocktower.NumberValue.Value == 0 then
        game.Workspace.Humanoid.Health = 0
    end
end




1 answer

Log in to vote
0
Answered by 8 years ago

You should use

player.TeamColor--But define player.

Because I don't think that a player goes into team folder when they join. But in ~~~~~~~~~~~~~~~~~ game.Players ~~~~~~~~~~~~~~~~~ Thats the purpose of player.TeamColor

0
Can you be more specific? I am aware of the player.TeamColor command, but how would that help me here? Malefactus 55 — 8y
0
Well, you should use player.TeamColor.Changed, because there is no PlayerAdded in a team. ScriptFusion 210 — 8y
0
Oh ok. I will try that and see how it goes! :) Malefactus 55 — 8y
0
Did it work? If so can you accept my answer? It gives us both rep! ScriptFusion 210 — 8y
Ad

Answer this question