Something is destroying my player Character on my Skill Script

I created that skill:

https://gyazo.com/b90aaceee41e3fcfaa67b8b772623fc6

the skill holds all the players around you within that sphere, and stun them and silence them (you cannot use skill while silenced) and the skill makes you “unstoppable” (you cannot be stunned)

so for that I created a module for the effects and a module to activate each effect

That module have all effects on table:


    local Effects = {}

local module = {}
 
   function module.New(c)
	  return {
		["Stunned"] = nil;
		["Silenced"] = nil;
		["Traped"] = nil;
		["Unstoppable"] = nil
	  }
   end

   function module.Get(c, effect)
      if not Effects[c] then
	    return nil
      else  
	    return Effects
	  end	
   end

   function module.Set(c,c2,effect)
	  if Effects[c] == nil then
		 Effects[c] = module.New(c)
	  end 
	  Effects[c][""..effect] = c2
   end


   function module.Remove(c,effect)
	  for index = 1, #Effects do
		 if Effects[index][""..effect] == c then
			Effects[index][""..effect].Value = nil
		 end
	  end
   end

return module

The key in the table Effects is the character of the player, and the values ​​are the character of the player that caused the effect

And that is the module that Stun the player:


    local StunEvent = game.ServerStorage.Events.Stun
local Effects = game.ServerStorage.Effects
local Stun = game.ServerStorage.Events.Stun

local module = {}

    function module.Check(character)
	   if Effects.Get(character,"Unstoppable") or Effects.Get(character,"Traped") or Effects.Get(character,"Stunned") then
		  return false
	   else
	      return true
	   end
    end 

    function module.StunPlayersAround(character,distance,Time)
	    local p = game.Players:GetPlayers()
	    local list = {}
	    for i = 1, #p do
		    local c = p[i].Character
		    if character ~= c and module.Check(c) == true and c:DistanceFromCharacter(character) <= distance then
			   Effects.Set(c,character,"Stunned")
			   c:WaitForChild("HumanoidRootPart").Anchored = true
			   Stun:Fire(c)
			   table.insert(list,c)
			   if Time > 0 then
				 module.RemoveStun(c,Time)
			   end
		    end
	    end
	    return list
    end 

   function module.RemoveStun(character,Time)
	   wait(Time)
	   Effects.Remove(character,"Stunned")   
   end

return module

And the silence one:

local Effects = game.ServerStorage.Effects

local module = {}

   function module.Check(character)
	 if Effects.Get(character,"Silenced") or Effects.Get(character,"Unstoppable") then
		 return false
	 else
		 return true
	 end	
   end

   function module.SilencePlayersAround(character,distance,Time)
	    local p = game.Players:GetPlayers()
	    for i = 1, #p do
		    local c = p[i].Character
		    if character ~= c and module.Check(c) == true and c:DistanceFromCharacter(character) <= distance then
			   Effects.Set(c,character,"Silenced")
			   if Time > 0 then
				 module.RemoveSilence(c,Time)
			   end
		    end
	    end
    end 

   function module.RemoveSilence(character,Time)
	   wait(Time)
	   Effects.Remove(character,"Silenced")
   end
   

return module

For some reason the fact that I use module.RemoveStun or module.RemoveSilence is destroying the character of the player

I know because i teste if i remove that line


and that
stop destroying the caracter, idk why this is happen, make no sense for me,
I thought that was it

    function module.Remove(c,effect)
	  for index = 1, #Effects do
		 if Effects[index][""..effect] == c then
			Effects[index][""..effect].Value = nil -- I thought this was removing the character 
                                                                                   from the player not only from the table 
                                                                                   but also from the game, but I removed 
                                                                                   that line and it remains the same
		 end
	  end
   end

That IS skill script

I made a lot of tests and that still making no sense for me, i dont have idea what to do, that is the copy if you guys want try, only press F to use the skill, please anyone smart enought helpme Again.rbxl (4.9 MB)

i would add a varible that gets the player who sets off the skill and add a and not -insert your character varible here- after the line of code that affects the players inside the sphere. this should then affect the player’s charcters inside the sphere, but not your character

I still not understanding How this is destroying my caracter

try checking your code. something could be in there that destroys the character.
it could be:

  • when you stun them
  • when you silence them
  • the skill itself when it makes you “unstoppable”
  • the possibility that removing the silence effect from the player gets rid of the players character, instead of removing the active effect(might actually be the reason why it destroys the character in the first place, if the silence effect goes to the casters character too)

Is only when i try remove stun or remove silence

I putted the skill code, here local ReplicatedStorage = game:GetService("ReplicatedStorage")local DarkZone = - Pastebin.com

The issue is that you are doing Effects = game.ServerStorage.Effects. For one thing, use GetService as it’s 100% reliable whereas directly indexing is not. Secondly, this is an instance. At the bottom of the script you do Effects.Remove(character, ...) This gets the deprecated Remove function of Effects (which is an instance). You should use WaitForChild or FindFirstChild: Effects:WaitForChild("Remove")

Look the skill code local ReplicatedStorage = game:GetService("ReplicatedStorage")local DarkZone = - Pastebin.com

I’ve already told you what the issue is. You are calling the Remove function of an instance. Effects is an instance. You are not requiring it.

Thanks i Will try Tomorrow and If work i will put as solution

Alright! I’ll give exact line numbers and an explanation.

Line 3 of the code where you say “And that is the module that Stun the player:” is local Effects = game.ServerStorage.Effects. Judging by your other code you mean local Effects = require(game.ServerStorage.Effects). I’m also assuming the other variables (StunEvent and Stun) are supposed to require as well.

On the line 4 lines above the bottom of your script you call Effects.Remove which is a function you’ve defined in the Effects module I’m guessing. You haven’t required it so it’s actually a ModuleScript instance that you’re indexing. You’re calling Remove which is a deprecated function on instances. By passing character as the first argument and using . it’s like calling character:Remove("Stunned") instead.

StunEvent is only a bindable event

Ah okay. You’re also missing require for Effects in some other scripts it looks like.

So the problem is that Remove already is a method on ROBLOX ?

Sort of. The problem is that you aren’t requiring Effects so instead of having the table the Effects module returns you have an Instance (the ModuleScript Effects itself) and Instances have a Remove function (which is deprecated in favor of Destroy which behaves slightly differently).

Alrg, but my effects system is good? Is easy to use and i can call on ALL skills

It looks pretty good to me! Hopefully there won’t be too much more beyond the fact that you’re not requiring it.