you can name functions and add parameters to them for instance. v
function FlipCoin(side)
function indicates that it is a function, FlipCoin is the name of the function and side is the parameter.
yes, you tell the script to find the number after you tell it what to do when it finds the number
function FlipCoin(side)
if side == 1 then
return "heads"
elseif side == 2 then
return "tails"
end
end
when you use == the code is basically asking "is this equal to this?" = is basically "this is now equal to this" you need 2 ends because you need to end the function, then you need to end the if statement, elseif is something you can do to minimize your lines if you don't want to do that you can use embedded if statements if you have embedded if statements you need to put more ends
to make it find the number you will need to do math.random() which means it finds a random number, like this. v
math.random(1,2)
putting all this together it would look like
function FlipCoin(side)
if side == 1 then
return "heads"
elseif side == 2 then
return "tails"
end
end
print(FlipCoin(math.random(1,2)))
if you want to make a more complicated rng then you can do the 1,2 format but change the 2 to any number you want and thats how many variables there will be