I have a custom chat GUI that is meant to choose a random text color for everyone and the owner and admins have a prefix in front of their name (they can also buy a gamepass to choose their on color but I havent set that up fully). The problem is it makes everyone a owner and they all have the samr color text. Here is script:
ChatColors = {"Bright blue","Bright red","Bright green","Bright yellow","Bright orange","Bright violet","White","Black","Pink","Brown"}
BannedWords = {"crap"}
CustomColor = 00000000
OPrefix = "[OWNER]"
Owners = {"Krazykaram","",""}
APrefix = "[ADMIN]"
Admins = {"","",""}
game.Players.PlayerAdded:connect(function(player)
local SV = Instance.new("StringValue")
SV.Name = "SetColor"
SV.Value = ChatColors[math.random(1,#ChatColors)]
player.Chatted:connect(function(message)
if string.sub(message:lower(),1,3) == "/c " then
if game:GetService("MarketplaceService"):PlayerOwnsAsset(player,CustomColor) then
SV.Value = string.sub(message,4)
end
end
for i,a in pairs(game.Players:GetChildren()) do
b = a:FindFirstChild("PlayerGui"):FindFirstChild("CustomChat")
for i,c in pairs(b.ChatBox:GetChildren()) do
if c:IsA("TextLabel") then
c.Position = c.Position - UDim2.new(0,0,0.2,0)
if c.AbsolutePosition.Y <= 0 then
c:Destroy()
end
end
end
local d = game.ReplicatedStorage.Chat:Clone()
d.Parent = b.ChatBox
for i,v in pairs(BannedWords) do
if message:lower():find(v) then
d.Text = ""..player.Name.." tried to say a banned word!" break
end
end
if d.Text ~= ""..player.Name.." tried to say a banned word!" then
for i,x in pairs(Owners) do
if player.Name:lower():find(x:lower()) then
d.Text = ""..OPrefix.." "..player.Name..": "..message
else
for i,y in pairs(Admins) do
if player.Name:lower():find(y:lower()) then
d.Text = ""..APrefix.." "..player.Name..": "..message
end
end
end
end
if d.Text ~= ""..OPrefix.." "..player.Name..": "..message and d.Text ~= ""..APrefix.." "..player.Name..": "..message then
d.Text = ""..player.Name..": "..message
end
end
d.TextColor3 = BrickColor.new(SV.Value).Color
game.Debris:AddItem(d,30)
end
end)
end) |