local tool
if not tool then
print"e"
else
print"c"
end
it won't print "c" whatever I change 'tool' to, any help appreciated
local tool
if not tool then
print"e"
else
print"c"
end
it won't print "c" whatever I change 'tool' to, any help appreciated
I assume you're trying to assign a variable named tool to whatever value the ternary statement evaluates to? If this was the exact code you used, then you missed an equal '=' operator during the assignment.
local tool = if not tool then print("e") else print("c")
Keep in mind, however, that this only works if the tool is nil or false. Also, the variable named tool will be reassigned to whatever print() returns.
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
I also included parenthesis on the print function just for clarity. You can omit them for strings if you want
it's more like checking if a block exists in a game. if game.workspace.part then <- guessing this checks if a part exists
if you want to check if a block exists in workspace, you can use Part:IsDescendantOf(workspace)