I’m doing some of module practice, OOP, and something more. I wanted to keep the code simpler as much as I can. I’m curious why another module script doesn’t do the same as the main module script.
Module script
local Utility = {}
function Utility.isFound(object:Instance,DEBUG_MESSAGE:string)
if object then
return warn(DEBUG_MESSAGE)
end
end
return Utility
Another module (Specific line of code)
local MainUtility = require(game.ReplicatedStorage.Modules.MainUtility)
function Character:Clone(name)
-- this doesn't return
MainUtility.isFound(script.Parent:FindFirstChild(name),`is found {script.Parent:FindFirstChild(name)}`)
-- this does return
if script.Parent:FindFirstChild(name) then return warn(`is found {script.Parent:FindFirstChild(name)}`) end
local c = script.Parent.cloneFolder:Clone()
c.Name = name
c.Parent = script.Parent
Character:Preparing(c)
end
And the problem is that the “doesn’t return” one keep cloning folders. (I use while loop just to check if the method is called and found specific folder, then it should return and stop cloning more folders.)