I’m trying to create a script where the function has a value and is then put inside an if statement to do something. But I don’t know how to put a value inside a function. (like 10 + 10 going inside functionname() )
1 Like
Like this?
function someFunc(variable)
local newResult = variable * 2
if newResult == 20 then
-- some code
end
end
someFunc(10)
1 Like
You could just reference it inside the parameters? Your local function would already keep track of them as long as you have 2 parameters you want to check for, and you call the function outside itself:
local function AddNumbers(Integer1, Integer2)
local Sum = Integer1 + Integer2 --Adding the sum of 15 & 5
print(Integer1)
print(Integer2)
if Sum == 20 then
print("These numbers are equal to 20!")
end
end
AddNumbers(15, 5) --15 is Integer1, while 5 is Integer2