The roblox wiki says: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].
This basically, means that math.random is a random generator that fires from 1 to the argument you gave it so lets say our script is from 1 and to 100 it will pick any random number from that number code. And returns a uniform integer basically means it will return a full number.
All you have to do to pick a number and choose a function called math.random
x = math.random(1, 100)
print(x)
I made a simple script for you to understand
for a touched event all you have to do is
local debounce = true
part = script.Parent
part.Touched:Connect(function(hit)
if debounce then
if hit.Parent:FindFirstChild("Humanoid")
then
local x = math.random(1, 10)
wait(1)
print(x)
debounce = false
end
end
end)
Note: This will only fire once this is because we need a loop.
3 comments
Maybe try using a table and if you select one randomly you will use a function connected to that.
Please post more of the script. Especially the part with the array
edit:- fixed codeblock