When I use this code:
game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local rank = Instance.new("StringValue") rank.Name = "Rank" rank.Value = "Guest" rank.Parent = leaderstats while true do wait(1) if player:GetRankInGroup(5214294) == 255 then player.Team = Teams.Moderators rank.Value = "Owner" end end end)
It teams to "Moderators", then teams to Guests, and neutral goes on. Why does it do that? - Toby
Turns out the spawns were auto assignable on touch which caused the issue.
We ended up disabling that in the spawn's properties and changing up the script a bit to make it cleaner.
This is what the script looks like now:
local Teams = game:GetService("Teams") local ranks = { [255] = {RankName = "Owner", Team = game.Teams.Moderators}, [254] = {RankName = "Owner", Team = game.Teams.Moderators}, [253] = {RankName = "Developer", Team = game.Teams.Moderators}, [252] = {RankName = "High Level", Team = game.Teams.Moderators}, [200] = {RankName = "Ministry", Team = game.Teams.Moderators}, [150] = {RankName = "Professor", Team = game.Teams.Professor}, [3] = {RankName = "3rd year student", Team = game.Teams.Students}, [2] = {RankName = "2nd year student", Team = game.Teams.Students}, [1] = {RankName = "1st year student", Team = game.Teams.Students}, } game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local rank = Instance.new("StringValue") rank.Name = "Rank" rank.Value = "Guest" rank.Parent = leaderstats local rankInGroup = player:GetRankInGroup(5214294) if rankInGroup ~= 0 then player.Team = ranks[rankInGroup].Team player.leaderstats.Rank.Value = ranks[rankInGroup].RankName end end)
Hey Toby,
From line 10 on it checks if the player is in the group and ranks them. However, when they are not assigned as Owner nothing happens.
game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") local Teams = game:GetService("Teams") leaderstats.Name = "leaderstats" leaderstats.Parent = player local rank = Instance.new("StringValue") rank.Value = "Guest" rank.Parent = leaderstats if player:GetRankInGroup(5214294) == 255 then player.Team = Teams.Moderators rank.Value = "Owner" else player.Team = Teams.Guests rank.Value = "Guest" end end)
What I have done here for you is removed the while true do. The while true do will not be of any use once the players rank has been checked. I have also added an else to your if statement, that teams the player into Guests and sets their rank value to Guest if they are not in the group. This way the Player does not remain unassigned to a team.