As I’m rather new to scripting, I might require a reminder of how I would go about doing this. As I wish to retrieve a randomized value from the function, how would I do this? I’ve tried doing “If Roll() = Rock then” and this did not work as I wished it to. I’m currently trying to do this as a way to retrieve a randomized result from my array.
You pretty much have it:
if Roll() == "Rock" then
Roll() needs to return something though for this to work, so your function should look something along the lines of this:
local choices = {"Rock", "Paper", "Scissors"}
function Roll()
return choices[math.random(1, #choices)]
end
1 Like
Yes, I have an entire function that gives me a randomized result through a rarity system, so don’t worry about that!
local function someGetter()
return "aResult"
end
local result = someGetter()
if result == "aResult" then
print("Success")
end
This is a quick example of how to utilize function returns. @Locard is also correct in your specific case.
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.