I have here a respawn script that will respawn a mob (that it is parented to). thing is whenever the mob respawns my game just freezes for like 4 seconds, before returning to normal.
I do not want this to happen so all I want is a more optimized (less laggy) version of the script below:
local _M = require(script.Parent.MobConfig)
local Mob = script.Parent -- The mob
local Enemy = Mob.Enemy -- the Mob's Humanoid
MobClone = Mob:Clone() -- Clone the mob (the mob is an R15 rig so that might be the reason it lags)
function Respawn()
if (not Mob) then return end
wait(_M.RespawnTime)
script.Parent:Destroy()
MobClone.Parent = game.Workspace.MobHolder.GrassPeople -- the place the character respawns in
end
Enemy.Died:Connect(Respawn)

1 comment
Maybe switch lines 10 and 11?