Maybe try to comment out the CreateObject line from the Damage function and see if that’s the culprit?
_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(enemy)
end
return _Module