Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Group rank over head if not in group?

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)

2 comments

0

Im not rlly sure how, but heres a suggestion, maybe try to make it so if they r not in that group another script (that is always disabled untill the player isnt in group) that when it goes abled (disabled = false) the player has customer on their head

0

An easier way to see if a player respawns is by using the Player.CharacterAdded() function. http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded

2 answers

✓ Accepted answer

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)

1 comment

0

thanks!

You could put the following at the end of the first function.

if not newPlayer:IsInGroup(groupid) then
gui:Destroy()
end

1 comment

0

but i want it to say above their head "customer" if they aren't in the group

This discussion is preserved as it was. New answers, comments, and votes are closed.