I can just use IF statements and return end to stop functions but i don’t really want to do that because it doesn’t look good to me, and so i will create another function to pcall functions so that i don’t have to use if statements for all of my functions
How about this? Just a slight variation
function b(condition)
return 1 / condition
end
function a(condition)
b(condition)
print("Exec") --> only prints when condition is false
end
pcall(a,0) --> does not execute statements in "a" function
pcall(a,1)---> executes statements in "a" function
I tried it in rbx studio and 1/0 does not give an error, so function “a” statements will execute regardless of the pcall’s u made, i appreciate your help but i think i have already found my solution within my last post in this thread
Sure, I was just wondering how far we could push it without using if statements.
Interesting 1/0 doesn’t error, though, they must have already thought of that and return nil or something.
In studio, doing 0/0 returns nan
and according to typeof()
function its type is number, 1/0 gives inf
and its type is also a number, so it will not trigger an error, also for my case, if statements are necessary in the “b” function, to evaluate wether to continue the execution of function “a” or not, its probably not possible to completely abandon if statements, i just didnt like using them twice in both “a” and “b” function, and thankfully i can use IF statements only once in one of the functions now instead of using them in both functions
Lol, I like how typeof(NaN) is number, thanks.
This forum post has been fixed, can we stop necroposting?
I think i didn’t explain myself clearly here, first
by this i was refering to the problem i mentioned in my original post, which is now solved
by this, i mean using another function to pcall functions like this,
local function callfunction(funcname,var)
pcall(funcname,var)
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.