startScript re-entrancy has exceeded 3 error in Server Script Service

Just wanted to ask, I’m getting problems with startscript re-entrancy, but it’s really weird because i’m not cloning the script?? its in server script service too.

function where it errors

local function SpawnNPC(Zombie,GoToSpawn,CFrameOverright)
	if Zombie ~= "Summon" and not GoToSpawn then
		local audio = script.SpecialDeathSounds:FindFirstChild("Mystery"):Clone()
		local part = Instance.new("Part")
		local particles = game.ReplicatedStorage.MysteryParticles:Clone()
		particles.Parent = part
		particles.Enabled = true
		part.CFrame = CFrameOverright
		part.Parent = workspace.Props
		part.Anchored = true
		part.Transparency = 1
		part.CanCollide = false
		audio.Parent = part
		audio:Play()
		coroutine.wrap(thisIsUselessoutsideofMysterySpawnSound)(part,audio.TimeLength)
	end
	local model = game.ReplicatedStorage.NPCZombies:FindFirstChild(Zombie):Clone()
	local spawns = workspace.Spawns:GetChildren()
	if GoToSpawn then
		model.PrimaryPart.CFrame = (spawns[math.random(1,#spawns)].CFrame + Vector3.new(0,6,0))
	else
		model.PrimaryPart.CFrame = CFrameOverright
	end
	local castScript = game.ReplicatedStorage.CastDeathEvent:Clone()
	model.Behaviour.Enabled = true
	castScript.Parent = model
	castScript.Enabled = true
	local ragdollScript = game.ReplicatedStorage.RagdollScript:Clone()
	ragdollScript.Parent = model
	ragdollScript.Enabled = true
	model.Parent = workspace.NPCs
end

(Error happens at the end of the script (model.Parent = workspace.NPCs) so i’m not sure if thats important or by default) (This also spam clones the NPC meant to be spawned…)

also this error only occurs when an NPC (which is server side) calls it, when i call it via server script service scripts it works fimne

never found the bug but did a rework of some code and the error went away so hooray

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.