My game randomly crashes Im not sure why?

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

1 Like

Are there any “while true do” loops in any scripts without a wait()?

1 Like

nope i checked, theres only the Touched function but i have a debounce for it

I’ve noticed this code here. When the experience runs all the scripts in Server-Script-Service are untouchable(can’t be retrieved). So you should put the module in the Replicated-Storage. You can retrieve modules/scripts that are in Server-Script-Service, but only if that script is in Server-Script-Service.

However this shouldn’t cause the crash.

Have you tested running the game with one script requiring this module? Try putting prints in the module from 1st line to (in between getServices, animations, particles,etc.)

local module = {}

1 Like

ill check it out tommorow, the thing is i have a combat game with a dash and attack system i made a debounce on the server for each player but im not sure if that is the cause either, each time the player dashes it fires the event to the server and also each time the player hits but im not sure if that would cause the issue, ive tested insane amounts of events firing at the same time and it doesnt do that,
also when i crash it says please check your internet connection its the whole server crashing i tested it with my friends.

1 Like

i also read it could be the server memory usage issue how can i see the server usage being used and what is the max usage?

1 Like

You can see Stats under view.


However I have no clue what should be recommended for all the stats. I tried to look it up, but I found nothing( I’m currently having a laggy issue). Hopefully you can find something.

From what I could find of similar issues, It seems to be a Server Crash possibly by much strain, data leak(s), VFX , or complex stuff done on server and not client.

Similar Issue Links

Weird Internet Issue
Server disconnection, Error Code: 277 - #29 by VisionsInMyHead