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.
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