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

2 things. 1. Code error 2 Help to make a code for to custom make a model for a certain team? [closed]

Asked by 4 years ago

Hello. First thing, This is a alt account if you are wondering why the bacon hair. Other words on to the issue.

First issue.

local teams = game:GetService("Teams")
local tInfo = {
    ["Stalker"] = {
        MaxPlayers = 1;
    }
    ["Survivor"] = {
        MaxPlayers = 9;
    }
    ["Spectator"] = {
        MaxPlayers = 10;
    }
  }

local function countTeam(team)
    local count = 0
    for _, player in next, players:GetPlayers() do
        if player.Team == team then
            count = count + 1
        end
    end
    return count
end

local function assignRandomTeam(player)
    local assigned = false
    while not assigned do
        local randomTeam = teams:GetChildren()[math.random(#teams:GetChildren())]
        if randomTeam and countTeam(randomTeam) < tInfo[randomTeam.Name].MaxPlayers 
then
            player.Team = randomTeam
            assigned = true
        end
        wait(.5)
    end
end

Is the code i have to randomly select a player to a team. It was from a dev forum(Cant find it again). Also about how many people get in a team. When i run the command. It dose not randomize. it also gives me this error.

Workspace.Script Error 96,50 Expected ') (to close '{' at line 2),got '['

Also where do i place this. Do i keep it in the workshop or move it to a new file.

2 thing. Basically the title. i need some help creating a code that when a player joins a team they will be remodeled to a model i have.

Thank you.

Closed as Not Constructive by Nguyenlegiahung and killerbrenden

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 4 years ago

Add commas to the first tables contents

local tInfo = {
    ["Stalker"] = {
        MaxPlayers = 1;
    },
    ["Survivor"] = {
        MaxPlayers = 9;
    },
    ["Spectator"] = {
        MaxPlayers = 10;
    }
  }

And for the random team replace it with

local randomTeam = teams:GetChildren()[math.random(1,#teams:GetChildren())]
0
The comma's fixed the error. But for the local randomTeam. I replaced that on line 27 but it will still not do a randomize toxitman2account -7 — 4y
0
Are you calling the function and is this a normal script laurenbtd5 379 — 4y
0
It was a normal script i changed it to a local. Still doesn't work. Im new to coding so what you you mean calling on the function. toxitman2account -7 — 4y
Ad