In the video above, a proximity prompt is activated via an NPC, a particle effect plays, an animation plays, and then the NPC Disappears followed by another particle effect.
Both when the prompt is activated and when the NPC disappears there is a major lag spike
But here when I turn every single mesh transparency to 1, the lag is gone
The only thing I can think of is the accusive amount of mountain meshes, when I try to turn the render mode on performance, it says the mesh has too little tris. I can’t see a way to fix any of this.
Here is the script once the prompt is activated
if prompt.Name == "GiveJoke" and #jokes >= 1 and #jokes < player.HiddenStats.MaxJokes.Value + 1 then
local npc = prompt.Parent.Parent
local animation = npc.Animation
local npcHumanoid = npc.Humanoid
local stage = prompt.Parent.Parent.Parent
local laughAnim = npcHumanoid:LoadAnimation(animation.Laugh)
laughAnim.Priority = Enum.AnimationPriority.Action4
if prompt.Parent.Parent.Parent.Configuration.StageName.Value == "Field" then
quests.TellJokesAtFarm(game.ReplicatedStorage.Quest, player.Quests.TellJokesAtFarm)
end
laughAnim:Play()
local chat = chats[math.random(1, #chats)]
ChatService:Chat(npc.Head, chat, Enum.ChatColor.White)
prompt.Enabled = false
local coinNoises = npc.HumanoidRootPart.CoinSounds:GetChildren()
local randomCoinNoise = coinNoises[math.random(1, #coinNoises)]
randomCoinNoise:Play()
for i, v in pairs(jokes) do
spawn(function()
jokeAbility[v.Name]()
PlayParticalGroup(npc.HumanoidRootPart.LaughEffect, 3, npc.HumanoidRootPart.Position, ReplicatedStorage.Jokes[v.Name].Icon.Value)
end)
wait()
end
local popSound = game.StarterPlayer.Sounds.Pop
wait(3.3)
laughAnim:Stop()
popSound:Play()
spawn(function()
DisappearEffect(npc.HumanoidRootPart, npc.HumanoidRootPart.Cloud)
end)
wait()
npc:Destroy()
wait(3)
SpawnNpc(stage)