My game randomly crashes I have a feeling it might be this module script, I turned off other scripts and it seemed to work fine until i turn this one on unless I’m wrong, but if there is something wrong with this module script can someone tell me?
module script:
local rs = game:GetService(“ReplicatedStorage”)
local tws = game:GetService(“TweenService”)
local events = rs:WaitForChild(“Events”)
local stunrun = events:WaitForChild(“Movement”):WaitForChild(“StunRun”)
local attackstun = require(script.Parent:WaitForChild(“AttackStun”))
local debris = game:GetService(“Debris”)
local hitanims = script.Parent:WaitForChild(“HitAnimations”)
local hit1 = hitanims:WaitForChild(“Hit1”)
local hit2 = hitanims:WaitForChild(“Hit2”)
local slashparticles = script.Parent:WaitForChild(“CombatEffects”):WaitForChild(“SlashEffect”)
local stunmodule = require(game.ServerScriptService:WaitForChild(“StunHandlerV2”))
local module = {
normalslash = function (player,hits,holdingspace)
local combatsounds = script.Parent:WaitForChild(“CombatSounds”)
local hitbox = Instance.new(“Part”)
hitbox.CanCollide = false
hitbox.Transparency = 1
hitbox.Size = Vector3.new(7,1,5)
hitbox.Parent = workspace
if hitbox then
local weld = Instance.new(“Weld”)
weld.Parent = hitbox
weld.Part0 = hitbox
weld.Part1 = player.Character.HumanoidRootPart
weld.C0 = CFrame.new(0,0,4)
end
local hitdb = false
local hit
local att
local swing = combatsounds.Swing:Clone()
swing.Parent = player.Character.HumanoidRootPart
swing:Play()
stunrun:Fire(player.Character)
local playervel = Instance.new(“BodyVelocity”)
playervel.Parent = player.Character.HumanoidRootPart
playervel.MaxForce = Vector3.new(50000,50000,50000)
playervel.Velocity = player.Character.HumanoidRootPart.CFrame.LookVector * 30
debris:AddItem(playervel, 0.2)
hitbox.Touched:Connect(function(enemy)
if enemy.Parent:FindFirstChild(“Humanoid”) then
local enemyhum = enemy.Parent.Humanoid
local enemyroot = enemy.Parent.HumanoidRootPart
local playerhum = player.Character.Humanoid
local playerroot = player.Character.HumanoidRootPart
if hitdb == false then
hitdb = true
if enemy.Parent ~= player and enemyhum.Health > 0 then
if enemy.Parent.Blocking.Value == false then
attackstun.Stun(playerhum,1,8)
if hits.Value == 1 then
hit = combatsounds.Slash:Clone()
hit.Parent = enemy.Parent.HumanoidRootPart
hit:Play()
local hit1anim = enemyhum:LoadAnimation(hit1)
hit1anim:Play()
enemyhum:TakeDamage(2)
elseif hits.Value == 2 then
hit = combatsounds.Slash:Clone()
hit.Parent = enemy.Parent.HumanoidRootPart
hit:Play()
local hit2anim = enemyhum:LoadAnimation(hit2)
hit2anim:Play()
enemyhum:TakeDamage(2)
elseif hits.Value == 3 then
hit = combatsounds.Slash:Clone()
hit.Parent = enemy.Parent.HumanoidRootPart
hit:Play()
local hit1anim = enemyhum:LoadAnimation(hit1)
hit1anim:Play()
enemyhum:TakeDamage(3)
elseif hits.Value == 4 then
hit = combatsounds.Slash:Clone()
hit.Parent = enemy.Parent.HumanoidRootPart
hit:Play()
local hit2anim = enemyhum:LoadAnimation(hit2)
hit2anim:Play()
enemyhum:TakeDamage(3)
elseif hits.Value >= 5 then
hit = combatsounds.Slash:Clone()
hit.Parent = enemy.Parent.HumanoidRootPart
hit:Play()
stunmodule.Stun(enemyhum,3)
enemyhum:TakeDamage(7)
end
local blood = slashparticles.Blood:Clone();blood.Parent = enemyroot;blood:Emit(2)
local blooddrops = slashparticles.BloodDrops:Clone();blooddrops.Parent = enemyroot;blooddrops:Emit(7)
local effectatt = Instance.new(“Attachment”,enemyroot)
local slasheffect = slashparticles.Slash:Clone();slasheffect.Parent = effectatt;slasheffect:Emit(1)
if hits.Value <= 4 then
local enemyvel = Instance.new(“BodyVelocity”)
enemyvel.Parent = enemyroot
enemyvel.MaxForce = Vector3.new(50000,50000,50000)
enemyvel.Velocity = playerroot.CFrame.LookVector * 15
debris:AddItem(enemyvel, 0.2)
if holdingspace == true then
else
end
elseif hits.Value >= 5 then
local enemyvel = Instance.new(“BodyVelocity”)
enemyvel.Parent = enemyroot
enemyvel.MaxForce = Vector3.new(25000,25000,25000)
enemyvel.Velocity = playerroot.CFrame.LookVector * 50
debris:AddItem(enemyvel, 0.5)
end
else
end
end
else
end
end
end)
if hits.Value >= 5 then
attackstun.Stun(player.Character.Humanoid,1,0)
else
attackstun.Stun(player.Character.Humanoid,1,4)
end
wait(0.2)
if hits.Value >= 5 then
hits.Value = 0
else
end
hitbox:Destroy()
end
}
return module