So i made a script that shows the rank of the player in a specified group. The group rank part works but the problem is - everyone who is not in the group doesnt have a rank over their heads. I wanted to make it so the rank said "customer" if they were not in the group. Here is my script (you can scroll down to the not in group part)
groupid = 3309505 --Change this to your group ID. game.Players.PlayerAdded:connect(onPlayerRespawned)--(Do not chang)-- function onPlayerRespawned(newPlayer) wait(1) if newPlayer:IsInGroup(groupid) then gui=Instance.new("BillboardGui") gui.Parent=newPlayer.Character.Head gui.Adornee=newPlayer.Character.Head gui.Size=UDim2.new(3,0,1.25,0) gui.StudsOffset=Vector3.new(0,3,0) texta=Instance.new("TextBox") texta.Size=UDim2.new(1,0,1,0) texta.BackgroundTransparency = 1 texta.TextScaled = true texta.TextColor3 = Color3.new(255, 255, 255) texta.Text = ("- " .. newPlayer:GetRoleInGroup(groupid) .. " -") texta.Parent=gui w = game.Lighting.WepsGroup:GetChildren() for i = 1,#w do w[i]:Clone().Parent = newPlayer.Backpack --this is the part where i tried to script the "customer part" if newPlayer:IsNotInGroup(groupid) then gui=Instance.new("BillboardGui") gui.Parent=newPlayer.Character.Head gui.Adornee=newPlayer.Character.Head gui.Size=UDim2.new(3,0,1.25,0) gui.StudsOffset=Vector3.new(0,3,0) texta=Instance.new("TextBox") texta.Size=UDim2.new(1,0,1,0) texta.BackgroundTransparency = 1 texta.TextScaled = true texta.TextColor3 = Color3.new(255, 255, 255) texta.Text = ("Customer") texta.Parent=gui w = game.Lighting.WepsGroup:GetChildren() for i = 1,#w do w[i]:Clone().Parent = newPlayer.Backpack end end end function onPlayerEntered(newPlayer) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) end game.Players.PlayerAdded:connect(onPlayerEntered)
So instead of doing IsNotInGroup(), which is not a function, you can just add an else statement to your IsInGroup() function. I have edited your code below to show what I mean. You had it all correct, all you needed to do was add an else. I hope this helps.
groupid = 3309505 --Change this to your group ID. function onPlayerRespawned(newPlayer) wait(1) if newPlayer:IsInGroup(groupid) then gui=Instance.new("BillboardGui") gui.Parent=newPlayer.Character.Head gui.Adornee=newPlayer.Character.Head gui.Size=UDim2.new(3,0,1.25,0) gui.StudsOffset=Vector3.new(0,3,0) texta=Instance.new("TextBox") texta.Size=UDim2.new(1,0,1,0) texta.BackgroundTransparency = 1 texta.TextScaled = true texta.TextColor3 = Color3.new(255, 255, 255) texta.Text = ("- " .. newPlayer:GetRoleInGroup(groupid) .. " -") texta.Parent=gui w = game.Lighting.WepsGroup:GetChildren() for i = 1,#w do w[i]:Clone().Parent = newPlayer.Backpack end else gui=Instance.new("BillboardGui") gui.Parent=newPlayer.Character.Head gui.Adornee=newPlayer.Character.Head gui.Size=UDim2.new(3,0,1.25,0) gui.StudsOffset=Vector3.new(0,3,0) texta=Instance.new("TextBox") texta.Size=UDim2.new(1,0,1,0) texta.BackgroundTransparency = 1 texta.TextScaled = true texta.TextColor3 = Color3.new(255, 255, 255) texta.Text = ("Customer") texta.Parent=gui w = game.Lighting.WepsGroup:GetChildren() for i = 1,#w do w[i]:Clone().Parent = newPlayer.Backpack end end end game.Players.PlayerAdded:connect(onPlayerRespawned)--(Do not chang)-- function onPlayerEntered(newPlayer) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) end game.Players.PlayerAdded:connect(onPlayerEntered)
You could put the following at the end of the first function.
if not newPlayer:IsInGroup(groupid) then gui:Destroy() end