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

Remote event is getting wrong information, any help ?

Asked by 7 years ago
Edited 7 years ago

So, i was doing a discord connector. About chat, then everything goes fine with remote event. Exept that the remote event must recieve: Name, Msg, name is fine but Msg comes the same as the name. Here the scripts. I will block discord id for obvious reasons.

In LocalScript

plr = game.Players.LocalPlayer

plr.Chatted:connect(function(msg)
    game.ReplicatedStorage.RemoteEvent:FireServer(plr.Name, msg)
    print(msg)
end)
         /\

In here it prints the msg of the player like it should.

game.ReplicatedStorage.RemoteEvent.OnServerEvent:connect(function(name, msg)
local HTTPService = game:GetService("HttpService")
local url = "Blank text"

        name = tostring(name)
        print(msg)        

        local Data = {
        ["username"] = "[In-Game] "..name.."";
        ["content"] = "***"..msg.."***";
        }
Data = HTTPService:JSONEncode(Data)
HTTPService:PostAsync(url, Data)
end)

In here it prints the same as username. Any fix? Thx.

0
Use player instead of name, and use player.Name instead of tostring SebbyTheGODKid 198 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

In the line, game.ReplicatedStorage.RemoteEvent:FireServer(plr.Name, msg), it will send the name, not the object (player) to the RemoteEvent. By default, the first argument of a remote event is the player that fires the event. Your variable 'name' takes up this role. You do not explicitly state the player as it finds the player itself. Your line should be more like: game.ReplicatedStorage.RemoteEvent:FireServer(msg). In the server script, remove the 'name = line', putting name.Name in the username JSON.

Hope this helped!

Thanks,

Explosion

Ad

Answer this question