I am making an custom chat ui and it has this in a LocalScript
local m = game.Players.LocalPlayer:GetMouse() m.KeyDown:connect(function(k) if k == '/' then game.Players.LocalPlayer.PlayerGui.ChatUI.Frame.Frame.TextBox:CaptureFocus() game.Players.LocalPlayer.PlayerGui.ChatUI.Frame.Frame.TextBox.typing.Value = true elseif k == '\r' or k == '\n' then if game.Players.LocalPlayer.PlayerGui.ChatUI.Frame.Frame.TextBox.typing.Value == true then game.Players.LocalPlayer:Chat(game.Players.LocalPlayer.PlayerGui.ChatUI.Frame.Frame.TextBox.Text) -- This line doesn't work game.Players.LocalPlayer.PlayerGui.ChatUI.Frame.Frame.TextBox.typing.Value = false game.Players.LocalPlayer.PlayerGui.ChatUI.Frame.Frame.TextBox.Text = "Click here or press '/' to chat" end end end)
Now... how do I make the game.Players.LocalPlayer:Chat() work?
In an normal Script I have:
local chatstorage = game.Workspace.ChatStorage game.Players.PlayerAdded:connect(function(plr) plr.Chatted:connect(function(msg) local chat = Instance.new('Folder', chatstorage) local msgVal = Instance.new('StringValue', chat) msgVal.Name = 'Message' msgVal.Value = plr.Name..': '..msg local colVal = Instance.new('Color3Value', chat) colVal.Name = 'Color' colVal.Value = Color3.new(math.random(255)/255,math.random(255)/255,math.random(255)/255) end) end)
but it won't fire the plr.Chatted when I use the game.Players.LocalPlayer:Chat() in a LocalScript. How to fix this?
game.Players.LocalPlayer:Chat() can only be used by plugins and core scripts I believe.