Weird Navigational Mesh Behavior

I recently noticed that when I created new instances that were uncollideable, it made the navigational mesh take a very long time to load. I have been experimenting with this mechanic in map for multiple days, and have narrowed it down to the volcanos in the background erupting. When the volcanos are not erupting, the navigation mesh is very quick to load and thus everything is working as intended.

Here are videos showing the behavior:
Working as Intended - Working properly (The NPCs are not freezing)
Volcano Erupted - No Longer Working as Intended - Not working properly (The NPCs are freezing)

Me and another user have possibly narrowed it down to the volcano script itself.
Is this really intense on performance?

local LandingSites = script.LandingSites:GetChildren()
local Volcanos = script.Parent.Volcanos:GetChildren()
while true do 
	local Volcano = Volcanos[math.random(1,#Volcanos)]
	local SFX = script.Rumbling:Clone()
	SFX.PlaybackSpeed = math.random(5,10)/10
	local BoomSFX = script.Erupt:Clone()
	BoomSFX.PlaybackSpeed = math.random(10,13)/10
	SFX.Parent = Volcano.Main
	SFX:Play()
	BoomSFX.Parent = Volcano.Main
	for i,v in pairs(Volcano.Main:GetChildren()) do 
		if v:IsA("ParticleEmitter") then
			v.Enabled = false
		end
	end
	wait(math.random(3,8))
	SFX:Stop()
	for i,v in pairs(script:GetChildren()) do 
		if v:IsA("ParticleEmitter") then
			v:Clone().Parent = Volcano.Main
		end
	end



	for i = 1, math.random(4,6) do
		BoomSFX:Play()
		for i,v in pairs(game.Players:GetChildren()) do 
			if v.Character then
				local Shake = script.CameraShake:Clone()
				Shake.Parent = v.Character
				Shake.Disabled =false
			end
		end
		Volcano.Main.Flame.Enabled = true
		Volcano.Main.Flame2.Enabled = true
		Volcano.Main.Smoke:Emit(200)
		for index = 1, math.random(15,25) do 
			local LandingSite = LandingSites[math.random(1,#LandingSites)]
			Volcano.Main.Flame:Emit(15)
			local Rock = script.VolcanicRock:Clone()
			Rock.Position = Volcano.Main.Position + Vector3.new(math.random(-15,15),math.random(8,15),math.random(-15,15))
			Rock.Parent = game.Workspace.NPCStuff
			Rock.Size = Rock.Size + Vector3.new(math.random(0,4),math.random(0,4),math.random(0,4))
			for i, v in pairs(script.Parent.Structure.Borders:GetChildren()) do
				local NoCollide = Instance.new("NoCollisionConstraint",Rock)
				NoCollide.Part0 = Rock
				NoCollide.Part1 = v
			end
			local LandingSpot = LandingSite.Position + Vector3.new(math.random(-35,35),math.random(0,25),math.random(-35,35))
			-- Calculate Arch --
			local TravelTime = math.random(3,5)
			local Gravity = Vector3.new(0, -game.Workspace.Gravity, 0)
			local StartPos = Rock.Position
			local CalculatedVelocity = (LandingSpot - StartPos - 0.5*Gravity*TravelTime*TravelTime)/TravelTime
			-- Throw --
			Rock.RotVelocity = Vector3.new(math.random(-15,15),math.random(-15,15),math.random(-15,15))
			Rock.Velocity = CalculatedVelocity
			Rock.Anchored = false
			--Rock.HandleRock.Disabled = false
			wait(0.1)
		end

		Volcano.Main.Flame.Enabled = false
		Volcano.Main.Flame2.Enabled = false
		wait(math.random(3,5))
	end
	for i,v in pairs(Volcano.Main:GetChildren()) do 
		if v:IsA("ParticleEmitter") then
			if v.Name == "ParticleEmitter" then
				v.Enabled =true
			else
				v.Enabled = false 
				v.Parent = Volcano.Walls
				task.delay(10,function()
					v:Destroy()
				end)
			end
		end
	end

	wait(math.random(180,240))
end

Whoops, that’s my bad haha! Fixed it!

2 Likes

What exactly is the problem???

Because the navigational mesh is taking an extremely long time to load up. My NPCs (core aspect of the game, it’s entirely based off of them) go “afk” and freeze up.

Maybe the volcano is just too resource-intensive and is causing immense lag.

I don’t think so, even when I make it erupt only once, with 1-3 chunks, it still freezes up like this. Nothing else is lagging though. The chunks it fires all have a basic .touched event in their script but that’s basically it.

I’m no scripter but it’s gotta be the lag if it doesn’t happen when there isn’t a volcano.

Let me try disabling the scripts inside it, one sec.

1 Like

Even with the scripts inside the launched rocks disabled, it still causes the issue.

local LandingSites = script.LandingSites:GetChildren()
local Volcanos = script.Parent.Volcanos:GetChildren()
while true do 
	local Volcano = Volcanos[math.random(1,#Volcanos)]
	local SFX = script.Rumbing:Clone()
	SFX.PlaybackSpeed = math.random(5,10)/10
	local BoomSFX = script.Erupt:Clone()
	BoomSFX.PlaybackSpeed = math.random(10,13)/10
	SFX.Parent = Volcano.Main
	SFX:Play()
	BoomSFX.Parent = Volcano.Main
	for i,v in pairs(Volcano.Main:GetChildren()) do 
		if v:IsA("ParticleEmitter") then
			v.Enabled = false
		end
	end
	wait(math.random(3,8))
	SFX:Stop()
	for i,v in pairs(script:GetChildren()) do 
		if v:IsA("ParticleEmitter") then
			v:Clone().Parent = Volcano.Main
		end
	end



	for i = 1, math.random(4,6) do
		BoomSFX:Play()
		for i,v in pairs(game.Players:GetChildren()) do 
			if v.Character then
				local Shake = script.CameraShake:Clone()
				Shake.Parent = v.Character
				Shake.Disabled =false
			end
		end
		Volcano.Main.Flame.Enabled = true
		Volcano.Main.Flame2.Enabled = true
		Volcano.Main.Smoke:Emit(200)
		for index = 1, math.random(15,25) do 
			local LandingSite = LandingSites[math.random(1,#LandingSites)]
			Volcano.Main.Flame:Emit(15)
			local Rock = script.VolcanicRock:Clone()
			Rock.Position = Volcano.Main.Position + Vector3.new(math.random(-15,15),math.random(8,15),math.random(-15,15))
			Rock.Parent = game.Workspace.NPCStuff
			Rock.Size = Rock.Size + Vector3.new(math.random(0,4),math.random(0,4),math.random(0,4))
			for i, v in pairs(script.Parent.Structure.Borders:GetChildren()) do
				local NoCollide = Instance.new("NoCollisionConstraint",Rock)
				NoCollide.Part0 = Rock
				NoCollide.Part1 = v
			end
			local LandingSpot = LandingSite.Position + Vector3.new(math.random(-35,35),math.random(0,25),math.random(-35,35))
			-- Calculate Arch --
			local TravelTime = math.random(3,5)
			local Gravity = Vector3.new(0, -game.Workspace.Gravity, 0)
			local StartPos = Rock.Position
			local CalculatedVelocity = (LandingSpot - StartPos - 0.5*Gravity*TravelTime*TravelTime)/TravelTime
			-- Throw --
			Rock.RotVelocity = Vector3.new(math.random(-15,15),math.random(-15,15),math.random(-15,15))
			Rock.Velocity = CalculatedVelocity
			Rock.Anchored = false
			--Rock.HandleRock.Disabled = false
			wait(0.1)
		end

		Volcano.Main.Flame.Enabled = false
		Volcano.Main.Flame2.Enabled = false
		wait(math.random(3,5))
	end
	for i,v in pairs(Volcano.Main:GetChildren()) do 
		if v:IsA("ParticleEmitter") then
			if v.Name == "ParticleEmitter" then
				v.Enabled =true
			else
				v.Enabled = false 
				v.Parent = Volcano.Walls
				task.delay(10,function()
					v:Destroy()
				end)
			end
		end
	end

	wait(math.random(180,240))
end

if this is a really performance intensive script, I’m all ears on how to change it.

I don’t really know, this should probably go in #help-and-feedback:scripting-support cuz idk how to script lol

Alright, I guess I’ll move it then. Thanks for the help! (I’m quite new to actually making posts on here)

1 Like

np

all good if you need any additional help PM me