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

How to make LocalPlayer chat and bypass FE?

Asked by 5 years ago

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?

0
I can't think of a great solution, but maybe instead of using plr.Chatted you can set up a remote event that fires from the local script when you chat IceAndNull 142 — 5y
0
mouse.KeyDown is deprecated, and so is the second argument of Instance.new, and please use variables, don't repeat `game.Players.LocalPlayer`, and the fact that you need to check if the key pressed was carriage return or a newline ('\r', '\n') is disgusting, don't ever hurt my eyes ever again User#24403 69 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

game.Players.LocalPlayer:Chat() can only be used by plugins and core scripts I believe.

0
:/ BeAHacker666 75 — 5y
Ad

Answer this question