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

Help! How can I get one of these arguments in my remoteEvent function to work?

Asked by 3 years ago

I'm making a makeshift chat system that allows Xbox players to chat, but through the Developer console and by Print() since I'm too lazy to script a whole UI and all of the UI scripting.

(Just note that I'm somewhat new to RemoteEvents/RemoteFunctions)

I have a remoteEvent located in game:GetService('ReplicatedStorage') that fires to all clients with the player's name and the text that they want to send. Here I have a Server script that gets executed when you hit the Send button...

local btn = script.Parent
local cooldown = false

btn.MouseButton1Down:Connect(function()

    if cooldown == false then

        cooldown = true

        local RS = game:GetService("ReplicatedStorage")
        local RF = RS.Stuff.Remotes.SendMessageE

        local playerName = script.Parent.Parent.Parent.Parent.Parent.Name
        local inp = script.Parent.Parent.Frame.TextBox.Text

        RF:FireAllClients(playerName, inp)

        wait(5)

        cooldown = false

    elseif cooldown == true then

        warn("Please wait before sending another message.")

    end

end)

The "playerName" will be the sender's name, and the "inp" will be the input from the TextBox.

Then, I have a LocalScript in the same path as the Server script (underneath the "Send" button) containing the following script...

local RS = game:GetService("ReplicatedStorage")
local RE = RS.Stuff.Remotes:WaitForChild("SendMessageE")

RE.OnClientEvent:Connect(function(playerName, inp)
    print(tostring(playerName).." : "..tostring(inp))
end)

It should print out like this... [Timestamp] -- SenderNameExample : Hello!

But it ends up being this... [Timestamp] -- SenderNameExample : <-- No text at all, only the name and timestamp.

Any help please? I'm not gonna be on for a while because It's waayyy to late for me.

1
The User Interface belongs to the Client, and with FE regulations, any modification made will not reflect to the Server; the Server cannot see what you typed. You need to have the Client send their data to the Server in which is is then filtered and distributed. Ziffixture 6913 — 3y
0
So do I make another remoteEvent that sends the name and input data to the server to update it. Then, fire the first remoteEvent to all clients? Voltaicmimic 43 — 3y
0
Ok, I actually managed to fix this problem by doing what you said, Ziffixture. I went to another script for another remoteEvent that updates the input, then once it's sent to the server, I used :FireAllClients(player, input) on the server script. Then, on the localscript that receives the data, I used RE.OnClientEvent:Connect(function(player, input) to print the values of player and input. Voltaicmimic 43 — 3y
0
I went onto my test game with my alt account and main account to test it, everything is refreshing and sending properly like intended. Voltaicmimic 43 — 3y
0
Can you post that message you sent as an answer down there \/, so I can check it as the answer? Voltaicmimic 43 — 3y

Answer this question