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

Remote event not firing for some reason?

Asked by 3 years ago
Edited 3 years ago

So I was making my own chat and bubble chat system and I tried to use remote event to fire when the player talks. However, the remote event did not fire and it didn't show anything on the server and client. I did try to search on how to fix it but none of these answers seemed to work for me. Feel free to ask any questions.

ServerScriptService script:

game.ReplicatedFirst.ChatMessage.OnServerEvent:Connect(function(p, msg)
    local ChatGUI = p.Character:WaitForChild("BubbleChatUI")
    spawn(function()
        while wait(1) do
            Timer = Timer - 1
            if Timer < 0  then
                Timer = 0
                ChatGUI.Enabled = false
            end
        end
    end)
    print("Chat message detected.")
    msg = game:GetService("Chat"):FilterStringForBroadcast(msg, p)
    ChatGUI.Enabled = true
    local val = Instance.new("StringValue", workspace.chatMessages)
    val.Name = p.Name
    val.Value = msg
    ChatGUI.MessageLabel.TextLabel.Text = msg
    Timer = 4
end)

TextBox localscript:

script.Parent.FocusLost:Connect(function(EnterPressed)
    if EnterPressed then
        game.ReplicatedFirst:WaitForChild("Events").ChatMessage:FireServer(script.Parent.Text)
        script.Parent.Text = ""
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Don't use ReplicatedFirst, put your remote event in ReplicatedStorage, and switch your code to define ReplicatedStorage instead of ReplicatedFirst and it will work, this is because ReplicatedStorage is used to communicate between client and server since it's on both

0
Thank you! Works really well for me now. VitGamer123br 32 — 3y
0
np Averted_Vision 177 — 3y
Ad

Answer this question