Alright so I'm trying to add an owner thing to my chat gui so that it displays my name as [OWNER] if i type in the chat, but the thing that say rankCheck says for me to try to make it a local
Heres what the script looks like:
local OwnerID = 90519431
function NewLabel(parent, msg, player)
newchatline = Instance.new("TextLabel", parent)
newchatline.Text = rankCheck(player) .. "" .. player.Name.. ": " ..msg
newchatline.Size = UDim2.new(1,0,0,15)
newchatline.Position = UDim2.new(0,0,1,-15)
newchatline.Font = "SourceSansBold"
newchatline.TextColor3 = Color3.new(1,1,1)
newchatline.TextStrokeTransparency = 0
newchatline.BackgroundTransparency = 1
newchatline.BorderSizePixel = 0
newchatline.FontSize = "Size18"
newchatline.TextXAlignment = "Left"
newchatline.TextYAlignment = "Top"
newchatline.ClipsDescendants = true
newchatline.Name = "line1"
function rankCheck(player)
local done = false
if player.UserId == OwnerID and done == false then
done = true
return "[OWNER] "
end
end
end
function UpdateOldLabels(Parent)
for i,v in pairs(Parent:GetChildren()) do
if v.Name:sub(1,4):lower() == "line" then
local LineNumber = v.Name:sub(5)
if LineNumber == "12" then
v:Destroy()
else
v.Name = "line"..tostring(tonumber(LineNumber) + 1)
v.Position = v.Position - UDim2.new(0,0,0,15)
end
end
end
end
game:GetService("Players").PlayerAdded:connect(function(player)
player.Chatted:connect(function(msg)
for _,v in ipairs(game:GetService("Players"):GetChildren()) do
UpdateOldLabels(v:WaitForChild("PlayerGui").CustomChat.ChatHold)
UpdateOldLabels(game:GetService("StarterGui").CustomChat.ChatHold)
NewLabel(v:WaitForChild("PlayerGui").CustomChat.ChatHold, msg, player)
NewLabel(game:GetService("StarterGui").CustomChat.ChatHold, msg, player)
end
end)
end) |