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

how do i make it so there is only 1 player per team ?

Asked by
oziase 1
5 years ago
Edited 5 years ago

how do i make it so i there can only be one person per team so when they step on the spawn pad they get that team and nobody else can be on that team until they leave cinda like super hero tycoon but my game is free build with btools so i need teams so there is a plot for each team

1 answer

Log in to vote
0
Answered by
Farsalis 369 Moderation Voter
5 years ago
Edited 5 years ago

Hello, This Code Should Work.

This Is A Script

local plrs = {}
local team = game:GetService("Teams"):WaitForChild("YourTeam",3)

game.Workspace.YourPart.Touched:Connect(function(hit)
    if plrs[1] == nil and hit.Parent:WaitForChild("Humanoid", 3) then
        print("Here")
        local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
        plr.Team = team
        table.insert(plrs, plr.Name)
        game:GetService("Players")[plrs[1]].Team.PlayerRemoved:Connect(function()
            table.remove(plrs, 1)
        end)
    end
end)


Hope This Helped!

Ad

Answer this question