My goal is to make a script that assigns a character to a player based on their rank in my group.
Here is the code
local Player = nil
function character()
local player = Player
local groupid = 15545437
local role = player:GetRoleInGroup(groupid)
local animate = player.Character.Animate:Clone()
local team = player.Team
local teamname = player.Team.Name
local item = game.ReplicatedStorage:FindFirstChild(teamname)
local char = item:Clone()
char.Parent = game.Workspace
char.Name = player.Name
player.Character = char
animate.Parent = char
player.Character.RankHat.Handle.Gui.Frame.Text.Text = role
end
function PlayerAdded(player)
Player = player
local groupid = 15545437
local role = player:GetRankInGroup(groupid)
local Teams = game:GetService("Teams")
if role >= 2 and role <= 7 then
player.Team = Teams["[C] Combatants"]
character()
elseif role >= 8 and role <= 11 then
player.Team = Teams["[B] Operations"]
character()
elseif role >= 251 and role <= 252 then
player.Team = Teams["[A] Administration"]
character()
elseif role >= 253 and role <= 255 then
player.Team = Teams["[X] Command"]
character()
elseif role <= 1 then
player.Team = Teams["[D] Pre-Applicant"]
character()
end
end
game.Players.PlayerAdded:Connect(PlayerAdded)
This is a very sloppy script as some of you can probably tell already, and I am facing various errors regarding animations, respawning, etc. (Any support is appreciated)
But my main problem is that the character assignment does not work for the final rank in the script, being “[D] Pre-Applicant”.
I have tried looking for any spelling mistakes and found none, I am also willing to say that I am a bit out of my element as this is easily the most complicated script i’ve ever written.
If you can notice any obvious mistakes, please let me know as I am pretty much desperate here.