I’m so confused about this, for me it doesn’t even make sense.
So, I created module something like stunning for certain amount of time. I wanted to implement metamethods there(even without them it doesn’t seem to work). I used __call metamethod which fires when table being called as function. BUT, the main problem is that it doesn’t seem to return boolean as it should?? It returns nil…
local mt = {}
local module = {}
local Stunned = {} --table i have problem with
setmetatable(module,mt)
function Stun(Character,Time)
coroutine.resume(coroutine.create(function()
local Humanoid = Character.Humanoid
if Stunned[Character] then return end
Stunned[Character] = true--you can see im setting to true???
Humanoid.WalkSpeed = 0
Humanoid.AutoRotate=false
Humanoid.JumpPower=0
wait(Time)
Stunned[Character] = false -- and then to false...
Humanoid.WalkSpeed = 16
Humanoid.AutoRotate=true
Humanoid.JumpPower=50
end))
end
mt.__call = function(self,...)
local args = {...}
local call = args[1]
if call=="GET" then
local chr = args[2]
return Stunned[chr] --returns nil????
end
if call=="STUN" then
local chr = args[2]
local tim = args[3]
Stun(chr,tim)
end
end
return module
And to add, the module is in ServerStorage, it does return value only with commandbar. ( not in any scripts(im using modulescript but i tried default script, i also tried parenting module to workspace )