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

Why won't this script work?

Asked by 10 years ago

So yesterday i had asked how i could add chat colors to certain ranks and someone edited my script but it doesn't work. Any ideas on how to make this work? I was also wondering if someone could add some code to it so that the script doesn't break if someone is a rank that isn't specified in the script. My scripting isn't all that great

-- Put this script in the StarterGui.
-- Then change the GroupId to your Group's Id.

local GroupId = 1141758

local TextColorByRank = {
    "Member" = Color3.new(140/255, 2/255, 5/255),
    "President" = Color3.new(140/255, 59/255, 230/255),
    "Owner" = Color3.new(1/255, 1/255, 1/255),
}

while not Game.Players.LocalPlayer do wait() end
local plr = game.Players.LocalPlayer
local head = plr:WaitForChild("Head")
if plr:IsInGroup(GroupId) then
    local gui = Instance.new("BillboardGui", head)
    gui.Adornee = head
    gui.Size = UDim2.new(100,0,1,0)
    gui.StudsOffset = Vector3.new(0,3,0)
    gui.Name = "RankGui"
    local rank = Instance.new("TextLabel", gui)
    rank.Name = "Rank"
    rank.BackgroundTransparency = 1
    rank.BorderSizePixel = 0
    rank.ZIndex = 2
    rank.Font = "ArialBold"
    rank.Text = plr:GetRoleInGroup(GroupId)
    rank.Size = UDim2.new(1,0,1,0)
    rank.TextColor3 = TextColorByRank[plr:GetRoleInGroup(GroupId)] --The line I changed.
    rank.TextStrokeColor3 = Color3.new(0,0,0)
    rank.TextStrokeTransparency = 0
    rank.TextScaled = true
    rank.TextWrapped = false
end

1 answer

Log in to vote
0
Answered by 10 years ago

Ah, there is a very simple mistake. You can't assume that GroupId is going to be recognized as a registered object. GroupId is unrecognized to Roblox LUA. Use the full group link and put the link in the next line. Hope this helps!

0
Not really sure what you mean Alpha_Toon 57 — 10y
Ad

Answer this question