Hi! I’m currently trying to send an HTTP request to my external database everytime a user chats, I already have it sending the username and message however I can’t seem to add math.random?

Here is what I’m trying to do.

game.Players.PlayerAdded:connect(function(Player)
Player.Chatted:connect(function(Message)
local Data = {
['username'] = Player.Name,
["content"] = "Player: "..Player.Name.." ".."\nMessage: "..Message.." ".."\nChat Id: "..math.random
}
local NewData = HttpService:JSONEncode(Data)
HttpService:PostAsync(Webhook,NewData)
end)
end)

You need to add two parameters, the minimum number and the maximum number.

numbermath.random ( number m = 0.0, number n = 1.0 )
This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.) When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n].

Also, you should use :Connect instead of :connect.

Hey,
You’re missing the parenthesis for the math.random function which may be why it’s behaving weirdly. Try using math.random() instead, to get something like this: ["content"] = "Player: "..Player.Name.." ".."\nMessage: "..Message.." ".."\nChat Id: "..math.random().

@aixziie

This is incorrect. math.random(), math.random(10), and math.random(1, 10) all work fine. The parameters are optional unless you want to specify them with specifics.

No, you don’t need the number m and number n. In the API reference, those are just placeholders, to differentiate the numbers. Math.random using min, max, which is (minimum number, max number)