alright so on my previous question i got a answer from incap to use :FilterStringForBroadcastAsync()
which i did but im not entirely sure how to use it in the chat system i have set up. This chat system is a series of GUI elements and once a player chats it creates a textlabel and sets it in the appropriate place which did work before adding filter which now results in "a nil value" the script will say when a player joins and leaves but now it wont show their chat and instead give an immediate nil value error.
lines 93 and 100 are the lines with :FilterStringForBroadcastAsync()
on them everything else works fine
script:
local chats = script.Parent.Chats local last function newChat(msg,plr) local plrid = plr.UserId if #msg > 0 then for i, c in pairs(chats:GetChildren()) do c.Position = c.Position - UDim2.new(0, 0, 0.1, 0) end local newMessage = script.Message:clone() if #chats:GetChildren() == 10 then chats:GetChildren()[1]:Destroy() end if plrid == 38270341 then newMessage.TextColor3 = script.Owner.Value newMessage.Text = "[OWNER] " .. plr.Name ..": ".. msg elseif plrid == 291995028 or plrid == 131541716 or plrid == 41163273 or plrid == 291995028 then newMessage.TextColor3 = script.Admin.Value newMessage.Text = "[ADMIN] " .. plr.Name ..": ".. msg elseif game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plrid,5286942) then newMessage.TextColor3 = script.VIP.Value newMessage.Text = "[VIP]" .. plr.Name ..": ".. msg else newMessage.Text = plr.Name ..": ".. msg end newMessage.Position = UDim2.new(0, 0, 0.9, 0) newMessage.Parent = chats last = newMessage end end function join(plr) for i, c in pairs(chats:GetChildren()) do c.Position = c.Position - UDim2.new(0, 0, 0.1, 0) end local newMessage = script.Message:clone() if #chats:GetChildren() == 10 then chats:GetChildren()[1]:Destroy() end if plr.UserId == 38270341 then newMessage.Text = "[CONSOLE] " .. plr.Name .. " joined the server!" newMessage.TextColor3 = script.OwnerJoin.Value newMessage.Position = UDim2.new(0, 0, 0.9, 0) newMessage.Parent = chats last = newMessage else newMessage.Text = "[CONSOLE] " .. plr.Name .. " joined the server!" newMessage.TextColor3 = script.CONSOLE.Value newMessage.Position = UDim2.new(0, 0, 0.9, 0) newMessage.Parent = chats last = newMessage end end function left(plr) for i, c in pairs(chats:GetChildren()) do c.Position = c.Position - UDim2.new(0, 0, 0.1, 0) end local newMessage = script.Message:clone() if #chats:GetChildren() == 10 then chats:GetChildren()[1]:Destroy() end if plr.UserId == 38270341 then newMessage.Text = "[CONSOLE] " .. plr.Name .. " left the server!" newMessage.TextColor3 = script.OwnerJoin.Value newMessage.Position = UDim2.new(0, 0, 0.9, 0) newMessage.Parent = chats last = newMessage else newMessage.Text = "[CONSOLE] " .. plr.Name .. " left the server." newMessage.TextColor3 = script.CONSOLE.Value newMessage.Position = UDim2.new(0, 0, 0.9, 0) newMessage.Parent = chats last = newMessage end end game.Players.PlayerAdded:Connect(function(plr) join(plr) end) game.Players.PlayerRemoving:Connect(function(plr) left(plr) end) game.Players.PlayerAdded:Connect(function(plr) plr.Chatted:Connect(function(msg) msg:FilterStringForBroadcastAsync(msg) newChat(msg, plr) end) end) for i, player in pairs(game.Players:GetPlayers()) do player.Chatted:Connect(function(msg) msg:FilterStringForBroadcastAsync(msg) newChat(msg,player) end) end