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

This suddenly doesn't work when it previously did?

Asked by
IXLKIDDO 110
9 years ago

So, the other day I was working on my script that was supposed to serve as when some player randomly joined in. I've run down the lines and saw that when a player connects, the script won't even run even when it previously did. Can someone tell me what happened?

game.Players.PlayerAdded:connect(function(plr)
    local GroupID = getGroupId(plr)
    PlayerRanks(plr, GroupID)
end)

All the functions are there and are working when run through ways that are not using the first line, however the first line in this snippit doesn't work. I even used the print command to track down the problem, and it was that first line. No errors are produced from this, and I'm not sure why it isn't working. Can someone help me?

EDIT: As per request here is the rest of the script:

local allies = game:GetService("GroupService"):GetAlliesAsync(2553045)
local enemies = game:GetService("GroupService"):GetEnemiesAsync(2553045)
local friendlies = {}
local spies = {}

function AboveText(plr, GroupID)
    if GroupID then
        local rank = plr:GetRoleInGroup(GroupID)
        return rank
    else
        local rank = "Visitor"
    end
end

function setAffiliations()
    for i, v in pairs(allies:GetCurrentPage()) do
        table.insert(friendlies, v.groupId)
        if not allies.IsFinished then
            allies:AdvanceToNextPageAsync()
        end
    end
    for i, v in pairs(enemies:GetCurrentPage()) do
        table.insert(spies, v.groupId)
        if not enemies.IsFinished then
            enemies:AdvanceToNextPageAsync()
        end
    end
end

function getGroupId(plr)
    setAffiliations()
    if plr:IsInGroup(2553045) then
        return "2553045"
    else
        for i, v in pairs(friendlies) do
            if plr:IsInGroup(v) then
                return v
            else
                for q, a in pairs(enemies) do
                    if plr:IsInGroup(a) then
                        return a
                    end
                end
            end
        end
    end
end

function PlayerRanks(plr, GroupID)
    repeat wait() until
        plr.Character
    local gui = Instance.new("BillboardGui", plr.Character.Head)
    gui.Size=UDim2.new(4, 0, 4, 0)
    gui.StudsOffset=Vector3.new(0, 2, 0)
    local text = Instance.new("TextBox", gui)
    text.Position = UDim2.new(0, -150, 0, 0)
    text.Size = UDim2.new(1, 300, 1, 0)
    text.Text = AboveText(plr, GroupID)
    text.FontSize = "Size24"
    text.TextColor3 = Color3.new(0, 0, 0)
    text.TextTransparency = 0.4
    text.TextWrapped = true
    text.BackgroundTransparency = 1
end

EDIT 2: Supposedly testing this out in roblox studio is the problem. It works in a game server. Asking for deletion from staff members.

1
Can you provide the code for the 'PlayerRanks' function? Goulstem 8144 — 9y
1
And the 'getGroupId' function too DigitalVeer 1473 — 9y

Answer this question