So through an event I use my SCP867Service:Test onto my Effect’s module
--Service script
function SCP867Service:Test(player)
Effect.Apply(self.PrintSomething, player, 10, 1, "Test")
wait(5)
Effect.Remove(self.PrintSomething, player, "Test")
end
--Module script
function effect.Apply(func, player, duration, tickSpeed, tag)
--Check if the player already has the effect, bad code we don't check nil cases
local owningPlayer = game.Players:GetPlayerFromCharacter(player.Parent)
if effectsStorage[owningPlayer] and not Macros.findValue(effectsStorage[owningPlayer], func) then
--Adding to all tables
local functionCoroutine = coroutine.create(function()func(player, duration, tickSpeed)end)
In debugging the values look correct, with the player being the humanoid I passed, duration being 10 and tickSpeed being 1. Which then executes a function in the original service script:
function SCP867Service:PrintSomething(player, duration, tickSpeed)
for i = 1, duration, 1 do
print("Testing count: ", i)
task.wait(tickSpeed)
end
end
However here player = 10, duration =1 and tickSpeed = nil
What causes this?
I did all debugging I could and found that somewhere between the module script and the function being executed in my coroutine an additional value was required. I added a patch work solution of passing an additional nil before my player to make my code work, but doesn’t seem like the proper solution.
local functionCoroutine = coroutine.create(function() func(nil, player, duration, tickSpeed)end)
gameking000 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.