I have a script that automatically assigns teams on join
there is a value given to the player that defaults to 1 if no data is found
there is another value inside the player that stores a string and its value is the player’s team name
there is a modulescript being used to keep track of teams
every element of the modulescript is a team using
game:GetService("Teams"):WaitForChild("teamname")
Output:
12: Attempt to index nil with ‘name’
local ranks = require(script.Parent:WaitForChild("Ranks")
function setteam(player: Player)
local rank: IntValue = player:WaitForChild("Rank")
if rank.Value <= 10 then
player.Team = ranks[rank.Value]
else
player.Team = ranks[11]
end
local rankname: StringValue = player:WaitForChild("leaderstats"):WaitForChild("Rank")
local team: Team? = player.Team
rankname.Value = tostring(team.Name)
end
game.Players.PlayerAdded:Connect(function(player: Player)
setteam(player)
player:WaitForChild("Rank").Changed:Connect(function()
setteam(player)
end)
end)
Perhaps the script accepts the value too early (before it was set). This may be due to the DataStore or other functions, please send a script or set the default value to 1. Example: