Need help with rank gear script

I was making a rank gear script and it gives you a keycard according to your team, but when I join the team nothing happens, I made sure the rank and group were good and still doesn’t work.

Script:

game.Players.PlayerAdded:Connect(function(plr)
		if plr.TeamColor == BrickColor.new("Toothpaste") then
			if plr:GetRankInGroup(6136064) == 3 then
				local sctool = game.ReplicatedStorage["Level 2 Card"]:Clone()
				sctool.Parent = plr:WaitForChild("Backpack")
			elseif plr:GetRankInGroup(6136064) == 4 then
				local sctool2 = game.ReplicatedStorage["Level 3 Card"]:Clone()
				sctool2.Parent = plr:WaitForChild("Backpack")
			elseif plr:GetRankInGroup(6136064) == 5 then
				local sctool3 = game.ReplicatedStorage["Level 4 Card"]:Clone()
				sctool3.Parent = plr:WaitForChild("Backpack")
			elseif plr:GetRankInGroup(6136064) == 6 or plr:GetRankInGroup(6136064) == 7 then
					local sctool4 = game.ReplicatedStorage["Level 5 Card"]:Clone()
					sctool4.Parent = plr:WaitForChild("Backpack")
			elseif plr:GetRankInGroup(6136064) == 8 or plr:GetRankInGroup(6136064) == 9 or plr:GetRankInGroup(6136064) == 255 then
					local sctool5 = game.ReplicatedStorage["Omni Card"]:Clone()
					sctool5.Parent = plr:WaitForChild("Backpack")
		end
	end
end)
1 Like

this is because you check if they are in the team whenever they just joined and not checking whenever their team changes.

Oh, so how do I fix that? I was so confused about what to add.

something like this:

game.Players.PlayerAdded:Connect(function(plr)
	plr.Changed:Connect(function()
		if plr.TeamColor == BrickColor.new("Toothpaste") then
			if plr:GetRankInGroup(6136064) == 3 then
				local sctool = game.ReplicatedStorage["Level 2 Card"]:Clone()
				sctool.Parent = plr:WaitForChild("Backpack")
			elseif plr:GetRankInGroup(6136064) == 4 then
				local sctool2 = game.ReplicatedStorage["Level 3 Card"]:Clone()
				sctool2.Parent = plr:WaitForChild("Backpack")
			elseif plr:GetRankInGroup(6136064) == 5 then
				local sctool3 = game.ReplicatedStorage["Level 4 Card"]:Clone()
				sctool3.Parent = plr:WaitForChild("Backpack")
			elseif plr:GetRankInGroup(6136064) == 6 or plr:GetRankInGroup(6136064) == 7 then
				local sctool4 = game.ReplicatedStorage["Level 5 Card"]:Clone()
				sctool4.Parent = plr:WaitForChild("Backpack")
			elseif plr:GetRankInGroup(6136064) == 8 or plr:GetRankInGroup(6136064) == 9 or plr:GetRankInGroup(6136064) == 255 then
				local sctool5 = game.ReplicatedStorage["Omni Card"]:Clone()
				sctool5.Parent = plr:WaitForChild("Backpack")
			end
		end
	end)
end)

just check for when something about the player changes and check the teamcolor.

2 Likes

Thank you, this worked perfectly! I was like “I think I may be in a black hole here” but you helped me!

1 Like