This title script is bugging

Everytime a player join it gives them a different title and doesn’t give them the ranks in this script

game.Players.PlayerAdded:Connect(function(player)
	wait(0.4)
	local groupRank = player:GetRoleInGroup(groupID)
	local Regiment = script.Rank.Frame.Regiment
	local clone = script.Rank:Clone()
	clone.Parent = game.Workspace:WaitForChild(player.Name).Head
	clone.Frame.Name1.Text = '.'..player.Name..'.'
	clone.Frame.Rank.Text = groupRank
	wait(0.2)
	if player:IsInGroup(10168242) and player:IsInGroup(7501445) and player:IsInGroup(10421551) and player:IsInGroup(10221234) and player:IsInGroup(10718990) == true then
		Regiment.Text = "ALL REGIMENTS"
		Regiment.TextColor3 = Color3.fromRGB(22,4,5)
	elseif player:IsInGroup(10168242) and player:IsInGroup(7501445) and player:IsInGroup(10421551) and player:IsInGroup(10221234) and player:IsInGroup(10718990) ~= false then
		Regiment.Text = "NO REGIMENT"
		Regiment.TextColor3 = Color3.new(255,0,0)
	elseif player:IsInGroup(10168242) then
		Regiment.Text = "[ETS]"
		Regiment.TextColor3 = Color3.fromRGB(11,222,255)
	elseif player:IsInGroup(7501445) then
		Regiment.Text = "[SF]"
		Regiment.TextColor3 = Color3.new(0,0,0)
	elseif player:IsInGroup(10421551) then
		Regiment.Text = "[GG]"
		Regiment.TextColor3 = Color3.fromRGB(155,22,188)
	elseif player:IsInGroup(10221234) then
		Regiment.Text = "[RMP]"
		Regiment.TextColor3 = Color3.fromRGB(122,99,222)
	elseif player:IsInGroup(10718990) then
		Regiment.Text = "[LP]"
		Regiment.TextColor3 = Color3.fromRGB(110,252,255)
		end

I am assuming the error was

if player:IsInGroup(10168242) and player:IsInGroup(7501445) and player:IsInGroup(10421551) and player:IsInGroup(10221234) and player:IsInGroup(10718990) == true then
	Regiment.Text = "ALL REGIMENTS"
	Regiment.TextColor3 = Color3.fromRGB(22,4,5)
elseif player:IsInGroup(10168242) and player:IsInGroup(7501445) and player:IsInGroup(10421551) and player:IsInGroup(10221234) and player:IsInGroup(10718990) ~= false then
	Regiment.Text = "NO REGIMENT"
	Regiment.TextColor3 = Color3.new(255,0,0)

In this piece of code, you’re basically just trying to detect if only one part of your condition is true or false. So to fix that, I would just do remove those, and for making a condition for the else if statement detecting if the player is in neither of those groups, I would just add not to every part of those conditions.

if player:IsInGroup(10168242) and player:IsInGroup(7501445) and player:IsInGroup(10421551) and player:IsInGroup(10221234) and player:IsInGroup(10718990) then
	Regiment.Text = "ALL REGIMENTS"
	Regiment.TextColor3 = Color3.fromRGB(22,4,5)
elseif not player:IsInGroup(10168242) and not player:IsInGroup(7501445) and not player:IsInGroup(10421551) and not player:IsInGroup(10221234) and not player:IsInGroup(10718990) then
	Regiment.Text = "NO REGIMENT"
	Regiment.TextColor3 = Color3.new(255,0,0)
end

If this script malfunctions, Try this: (basically I just move those two long if statements with the rest of the if function)

game.Players.PlayerAdded:Connect(function(player)
	wait(0.4)
	local groupRank = player:GetRoleInGroup(groupID)
	local Regiment = script.Rank.Frame.Regiment
	local clone = script.Rank:Clone()
	clone.Parent = game.Workspace:WaitForChild(player.Name).Head
	clone.Frame.Name1.Text = '.'..player.Name..'.'
	clone.Frame.Rank.Text = groupRank
	wait(0.2)
	if player:IsInGroup(10168242) then
		Regiment.Text = "[ETS]"
		Regiment.TextColor3 = Color3.fromRGB(11,222,255)
	elseif player:IsInGroup(7501445) then
		Regiment.Text = "[SF]"
		Regiment.TextColor3 = Color3.new(0,0,0)
	elseif player:IsInGroup(10421551) then
		Regiment.Text = "[GG]"
		Regiment.TextColor3 = Color3.fromRGB(155,22,188)
	elseif player:IsInGroup(10221234) then
		Regiment.Text = "[RMP]"
		Regiment.TextColor3 = Color3.fromRGB(122,99,222)
	elseif player:IsInGroup(10718990) then
		Regiment.Text = "[LP]"
		Regiment.TextColor3 = Color3.fromRGB(110,252,255)
	elseif player:IsInGroup(10168242) and player:IsInGroup(7501445) and player:IsInGroup(10421551) and player:IsInGroup(10221234) and player:IsInGroup(10718990) then
		Regiment.Text = "ALL REGIMENTS"
		Regiment.TextColor3 = Color3.fromRGB(22,4,5)
	elseif not player:IsInGroup(10168242) and not player:IsInGroup(7501445) and not player:IsInGroup(10421551) and not player:IsInGroup(10221234) and not player:IsInGroup(10718990) then
		Regiment.Text = "NO REGIMENT"
		Regiment.TextColor3 = Color3.new(255,0,0)
	end
end)

Note: This script has not been tested so I’m not certain if it would work or not.

Still it seems like its applying the title text to everyone in the server

local Regiment = script.Rank.Frame.Regiment
local clone = script.Rank:Clone()

Basically, I found out that you just set the Regiment variable to the Rank GUI that wasn’t cloned, you are just setting the value to the placeholder. But it’s a very easy solution,

local clone = script.Rank:Clone()
local Regiment = clone.Frame.Regiment
Full script
game.Players.PlayerAdded:Connect(function(player)
	wait(0.4)
	local groupRank = player:GetRoleInGroup(groupID)
	local clone = script.Rank:Clone()
	local Regiment = clone.Frame.Regiment
	clone.Parent = game.Workspace:WaitForChild(player.Name).Head
	clone.Frame.Name1.Text = '.'..player.Name..'.'
	clone.Frame.Rank.Text = groupRank
	wait(0.2)
	if player:IsInGroup(10168242) then
		Regiment.Text = "[ETS]"
		Regiment.TextColor3 = Color3.fromRGB(11,222,255)
	elseif player:IsInGroup(7501445) then
		Regiment.Text = "[SF]"
		Regiment.TextColor3 = Color3.new(0,0,0)
	elseif player:IsInGroup(10421551) then
		Regiment.Text = "[GG]"
		Regiment.TextColor3 = Color3.fromRGB(155,22,188)
	elseif player:IsInGroup(10221234) then
		Regiment.Text = "[RMP]"
		Regiment.TextColor3 = Color3.fromRGB(122,99,222)
	elseif player:IsInGroup(10718990) then
		Regiment.Text = "[LP]"
		Regiment.TextColor3 = Color3.fromRGB(110,252,255)
	elseif player:IsInGroup(10168242) and player:IsInGroup(7501445) and player:IsInGroup(10421551) and player:IsInGroup(10221234) and player:IsInGroup(10718990) then
		Regiment.Text = "ALL REGIMENTS"
		Regiment.TextColor3 = Color3.fromRGB(22,4,5)
	elseif not player:IsInGroup(10168242) and not player:IsInGroup(7501445) and not player:IsInGroup(10421551) and not player:IsInGroup(10221234) and not player:IsInGroup(10718990) then
		print("e")
		Regiment.Text = "NO REGIMENT"
		Regiment.TextColor3 = Color3.new(255,0,0)
	end
end)
1 Like

Thank you so so so so much. It’s very appreciated.