Having issues with Evercyan's Advanced RPG Kit

You need to return it like this:

local _Module = {}
-- script here
return _Module

Me and @ScriptFiIe have already discussed this a few posts before, but again it has been removed unexpectedly in this iteration of the ModuleScript, probably a mistake in undoing

Okay. So if I did read well this is for a issue with Evercyan thing.

It’s not an issue with Evercyan’s RPG kit, @OP just forgot to add the return _Module at the very end

The thing is it is working now but the lag is back so that is basically where we have started

Okay so even with that optimization it did the lag is still back? Could you format the entire ModuleScript in a code block so it’s easier to read to help fix some lag causing areas

Maybe cause your script is really long? I am not sure about the optimisation.

Length has no factor in lag, it’s how the code is working that’s lagging the game, there’s probably better ways to do what’s needed in the ModuleScript, the Server script and local script work fine and don’t require optimizations, it’s the ModuleScript that requires even more Optimizations I believe

_Module = {}
function CreateTag(plr,enemy)
if enemy ~= nil then
	if (enemy:FindFirstChild("Player_Tag")) then return end
	local tag = Instance.new("ObjectValue", enemy)
	tag.Name = "Player_Tag"
	tag.Value = plr
end
end
function DestroyTag(enemy)
if enemy ~= nil then
	local tag = enemy:FindFirstChild("Player_Tag")
	if tag ~= nil then tag:Destroy() end
end
end
local function CheckDistance(plr,tor,dist)
if (not tor) or (not tor.Parent) or (not tor.Parent:FindFirstChild("MobConfig")) then return end
if plr:DistanceFromCharacter(Vector3.new(tor.Position.X,tor.Position.Y,tor.Position.Z)) < require(tor.Parent.MobConfig).FollowDistance then
	return true else return false
end
end

That’s only a part of it, I need to see all of it, edit your post wih the full ModuleScript

Having trouble with this it was cropped lemme try again

_Module = {}
function CreateTag(plr,enemy)
	if enemy ~= nil then
		if (enemy:FindFirstChild("Player_Tag")) then return end
		local tag = Instance.new("ObjectValue", enemy)
		tag.Name = "Player_Tag"
		tag.Value = plr
	end
end

function DestroyTag(enemy)
	if enemy ~= nil then
		local tag = enemy:FindFirstChild("Player_Tag")
		if tag ~= nil then tag:Destroy() end
	end
end

local function CheckDistance(plr,tor,dist)
	if (not tor) or (not tor.Parent) or (not tor.Parent:FindFirstChild("MobConfig")) then return end
	if plr:DistanceFromCharacter(Vector3.new(tor.Position.X,tor.Position.Y,tor.Position.Z)) < require(tor.Parent.MobConfig).FollowDistance then
		return true else return false
	end
end

function addComas(str)
	return #str % 3 == 0 and str:reverse():gsub("(%d%d%d)", "%1,"):reverse():sub(2) or str:reverse():gsub("(%d%d%d)", "%1,"):reverse()
end

local function CreateObject(hit,dmg)
		local ObjModel = Instance.new("Model", workspace.DebrisHolder)
		local Obj = Instance.new("Part", ObjModel)
		-- Appearance
		Obj.BrickColor = BrickColor.new("Bright red")
		Obj.Material = Enum.Material.Neon
		Obj.Transparency = 1
		-- Data
		Obj.Position = hit.Parent:FindFirstChild("Head").Position + Vector3.new(math.random(-1.6,1.6),2,math.random(-1.6,1.6))
		-- Behavior
		Obj.Anchored = true
		Obj.CanCollide = false
		Obj.Locked = true
		-- Part
		Obj.Shape = Enum.PartType.Ball
		Obj.Size = Vector3.new(0.75,0.75,0.75)
		-- Billboard Gui
		local Gui = script.BillboardGui:Clone()
		Gui.Adornee = ObjModel:FindFirstChild("Part")
		Gui.TextLabel.Text = addComas(tostring(dmg)).." damage"
		Gui.Parent = ObjModel
		
		local ObjPos = Instance.new("BodyPosition", Obj)
		ObjPos.Position = Vector3.new(0,7.85,0)
		for i = 1,0,-0.1 do
			Obj.Transparency = i
			Gui.TextLabel.TextTransparency = i
			Gui.TextLabel.TextStrokeTransparency = i
			wait()
		end
		wait(0.50)
		for i = 0,1,0.1 do
			Obj.Transparency = i
			Gui.TextLabel.TextTransparency = i
			Gui.TextLabel.TextStrokeTransparency = i
			wait()
		end
		return ObjModel
	end
local _Module = {}
function _Module.Damage(plr,hit,enemy)
	local chr = plr.Character or plr.CharacterAdded:Wait()
	local tool = chr:FindFirstChildOfClass("Tool")
	if (not enemy) or (not hit) or (not tool) then return end
	local tor = hit.Parent:FindFirstChild("Torso")
	if (not hit.Parent) or (not tor) then return end
	if (game.Players:GetPlayerFromCharacter(enemy.Parent)) then return end
	if (not CheckDistance(plr,hit.Parent:FindFirstChild("Torso"))) then return end
	local config = require(tool.WeaponConfig)
	local dmg = math.random(config.MinDamage,config.MaxDamage)
	if (plr:FindFirstChild("leaderstats")) then
		if plr:FindFirstChild("Level") then
			dmg = dmg + (plr.leaderstats.Level.Value - 1)
		end
	end
	CreateTag(plr,enemy)
	enemy:TakeDamage(dmg)
	local ObjModel = CreateObject(hit,dmg)
	ObjModel:Destroy()
	DestroyTag(ObjModel)
end
return _Module

Try this out, get rid of all the code in your ModuleScript and paste this in

_Module = {}

function CreateTag(plr,enemy)
	if (enemy:FindFirstChild("Player_Tag")) then return end
	local tag = Instance.new("ObjectValue")
	tag.Name = "Player_Tag"
	tag.Value = plr
	tag.Parent = enemy
end

function DestroyTag(enemy)
	local tag = enemy:FindFirstChild("Player_Tag")
	tag:Destroy()
end

local function CheckDistance(plr,tor,dist)
	if (not tor.Parent:FindFirstChild("MobConfig")) then return end
	if plr:DistanceFromCharacter(tor.Position) < require(tor.Parent.MobConfig).FollowDistance then
		return true
	else 
		return false
	end
end

function addComas(str)
	local formatted = str
	while k ~= 0 do  
		formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
	end
	return formatted
end

local function CreateObject(hit,dmg)
	local ObjModel = Instance.new("Model")
	ObjModel.Parent = workspace.DebrisHolder
	local Obj = Instance.new("Part")
	-- Appearance
	Obj.BrickColor = BrickColor.new("Bright red")
	Obj.Material = Enum.Material.Neon
	Obj.Transparency = 1
	-- Data
	Obj.Position = hit.Parent:FindFirstChild("Head").Position + Vector3.new(math.random(-1.6,1.6),2,math.random(-1.6,1.6))
	-- Behavior
	Obj.Anchored = true
	Obj.CanCollide = false
	Obj.Locked = true
	-- Part
	Obj.Shape = Enum.PartType.Ball
	Obj.Size = Vector3.new(0.75,0.75,0.75)
	Obj.Parent = ObjModel
	-- Billboard Gui
	local Gui = script.BillboardGui:Clone()
	Gui.Adornee = ObjModel.Part
	Gui.TextLabel.Text = addComas(tostring(dmg)).." damage"
	Gui.Parent = ObjModel
	
	local ObjPos = Instance.new("BodyPosition")
	ObjPos.Position = Vector3.new(0,7.85,0)
	ObjPos.Parent = Obj
	for i = 1,0,-0.1 do
		Obj.Transparency = i
		Gui.TextLabel.TextTransparency = i
		Gui.TextLabel.TextStrokeTransparency = i
		wait()
	end
	wait(0.50)
	for i = 0,1,0.1 do
		Obj.Transparency = i
		Gui.TextLabel.TextTransparency = i
		Gui.TextLabel.TextStrokeTransparency = i
		wait()
	end
	return ObjModel
end
	
function _Module.Damage(plr,hit,enemy)
	if (not enemy) or (not hit) then return end
	local chr = plr.Character or plr.CharacterAdded:Wait()
	local tool = chr:FindFirstChildOfClass("Tool")
	if (not tool) then return end
	local tor = hit.Parent:FindFirstChild("Torso")
	if (not hit.Parent) or (not tor) then return end
	if (game.Players:GetPlayerFromCharacter(enemy.Parent)) then return end
	if (not CheckDistance(plr,tor)) then return end
	local config = require(tool.WeaponConfig)
	local dmg = math.random(config.MinDamage,config.MaxDamage)
	dmg = dmg + (plr.leaderstats.Level.Value - 1)
	CreateTag(plr,enemy)
	enemy:TakeDamage(dmg)
	local ObjModel = CreateObject(hit,dmg)
	ObjModel:Destroy()
	DestroyTag(ObjModel)
end

return _Module

The biggest thing I saw that may’ve affected performance was that it was immediately setting the parent of a part in CreateObject and then setting 10 or more properties

It is working but it’s still lagging

Is it the same lag as before or is it slightly better?

I can not really tell any difference might have increased it just a little bit tho but if 5 players were to hit an npc the server would probably crash

Could it be that the Debounce isn’t properly working? When you hit an enemy, does it only display one health indicator or maybe?

image

So when you hit an enemy there is a critical hit counter thing

Okay so I tested the kit on an alternative studio and it doesn’t lag but works