I havetried for a bit and i can’t find any solution other than loadstring(), like this
loadstring("if math.random(1,5) == 1 then return 'Burn' end")()
Is there any other way to write a function and immediately call it?
I havetried for a bit and i can’t find any solution other than loadstring(), like this
loadstring("if math.random(1,5) == 1 then return 'Burn' end")()
Is there any other way to write a function and immediately call it?
I didn’t understand your code but if you want to call a function, you would do:
local function test()
print("Hello") -- Just replace this with your code.
end
test() -- Calls the function, so it would print "Hello."
they just want a custom loadstring(), don’t see how the post is hard to understand
Let me give you another example:
local Var1 = function()
if math.random(1,3) == 1 then return 5 else return 1 end
end
print(Var1)
If i print Var, it will print out some thing that i can’t remember but the point is that Var1 does not run the function, i was wondering if there was a way to immediately run a function (Besides loadstring() instead of having to establish a variable and then call that.
So you would do if you didn’t want to store a functions inside a variable.
local function Var1()
if math.random(1,3) == 1 then return 5 else return 1
end
end
print(Var1)
this will print the function
try this instead
print(Var1())