What do you want to achieve? Keep it simple and clear!
So basically. Im making my own “Wait” module with methods like “Wait,WhenReached,Set and CancelWait”
What is the issue? Include screenshots / videos if possible!
My problem occurs at the wait method. How can i have the thread yield but at the same time also chain the methods shown below:
local WaitModule = require(game.ServerScriptService.ModuleScript).new()
WaitModule.Wait(5):WhenReached(5):Set(5)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I did ask something like this before which i got a solution for. But that solution doesnt quite work here. I also did some research before posting how to “Chain methods”. But found nothing.
I know that this is possible because ive seen this before in a code. Sadly my OOP skills arent the greatest. I know a decent amount but not that much to know how to chain methods xd.
But any help would be really cool because im stuck here obviously.
Heres the full module code in case you need it. Still a WIP though
local CustomWait = {}
CustomWait.__index = CustomWait
function CustomWait.new()
return setmetatable(CustomWait,{Cancel = false})
end
function CustomWait.Wait(Seconds: number)
local Cancel = getmetatable(CustomWait).Cancel
local Start = os.clock()
repeat game["Run Service"].Heartbeat:Wait() print("Hello") until os.clock() - Start >= Seconds or Cancel
return CustomWait
end
function CustomWait:WhenReached(Second: number)
print("Sup")
return CustomWait
end
function CustomWait:CancelWait()
end
function CustomWait:Set(Second: number)
end
return CustomWait