So, I am attempting to make my game log all chatted commands to my MySQL database through a mixture of PHP, MySQL, and Lua. I have finished the PHP code, but on my game code, I get the following error.
ServerScriptService.ChatManager:7: attempt to perform arithmetic on a string value
local player3 = game.Players.LocalPlayer local chatMessageEvent = game.ReplicatedStorage.ChatMessage hs = game:GetService("HttpService") game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) hs:GetAsync("http://url.com/Method=WriteToChatlog&PlayerName=" + player.Name + "&PlayerID=" + tonumber(player.UserId) + "&PlaceID=" + tonumber(game.PlaceId) + "&PlaceName=" + game.Name, true) end) end)
You're getting a simple error. You don't concatenate using a + sign. You're supposed to use two dots .. with lua. Here's your script fixed:
local player3 = game.Players.LocalPlayer local chatMessageEvent = game.ReplicatedStorage.ChatMessage hs = game:GetService("HttpService") game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) hs:GetAsync("http://url.com/Method=WriteToChatlog&PlayerName=" .. player.Name .. "&PlayerID=" .. tonumber(player.UserId) .. "&PlaceID=" .. tonumber(game.PlaceId) .. "&PlaceName=" .. game.Name, true) -- Notice how above I replaced all the + with .. -- The reason you got that error was because it thought you were trying to perform a math equation with two strings which doesn't work. end) end)
Hope I helped, if I did be sure to accept my answer ;)
Also, be sure to read this: Lua String Concatenation