Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Group rank over head if not in group?

Asked by 6 years ago

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)
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 lukebloxdaily 6 — 6y
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 User#17862 0 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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)
0
thanks! sweetlittlegirlohhl -22 — 6y
Ad
Log in to vote
0
Answered by
Aorda 43
6 years ago

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

if not newPlayer:IsInGroup(groupid) then
gui:Destroy()
end
0
but i want it to say above their head "customer" if they aren't in the group sweetlittlegirlohhl -22 — 6y

Answer this question