So im trying to call a function in a dictionary by searching for it with an argument and it isnt working
local StateEffects = {}
local States = {
OnFire = spawn(function(Target, Damage, Duration, Time)
local i = 0
repeat
Target.Character.Humanoid.Health = Target.Character.Humanoid.Health - Damage
wait(Time)
i = i + 1
until i == Duration
end)
}
function StateEffects:DealState(Target, State, ...)
local OtherArguments = {...}
States.State(Target, OtherArguments)
end
return StateEffects
its giving me an error - Attempt to call a nil value at line 26 (thats the line 4th line in DealState function)
You still need to make sure that State will always be a key in the States dictionary. As far as I can tell, the only State that exists is “OnFire,” and that one isn’t even a callable function, rather a thread.
Your OnFire definition refers to a thread which is returned by the spawn() function; Just remove the spawn, then OnFire would refer to a function that you could call.