Hi, i don’t know how i can make a random character system on spawn when the team of player is “Civil” here is the code template but no topics on what i want to do. It’s important, thanks for your time
local charsFolder = game:GetService("ReplicatedStorage"):WaitForChild("Chars")
local debounceTimers = {}
local function pickRandomChar()
local charList = charsFolder:GetChildren()
return charList[math.random(#charList)]
end
local function changeCharacter(player)
if player.Team.Name == "Civil" then
local newChar = pickRandomChar()
player:LoadCharacter(newChar.Name)
print("loaded")
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local b = debounceTimers[player.UserId]
if not b then
table.insert(debounceTimers, player.UserId)
changeCharacter(player)
wait(1)
local a = table.find(debounceTimers, player.UserId)
table.remove(debounceTimers, a)
end
end)
end)