[HELP] Creating Persistent NPCs

I am making a script for my server at 24/7 shops which spawns a NPC and you have to aim at him to get the money. The problem is that they are disappearing for no reason. Here is the code I have to create them, if someone knows what Im missing…

DecorRegister("storerobbery", 2)
		local clerk = CreatePed(5, clerkData["model"], position.x, position.y, position.z, position.h)
		Wait(500)

		SetEntityAsMissionEntity(clerk, true, true)
		 
		SetNetworkIdExistsOnAllMachines(PedToNet(clerk), true)
		SetEntityCanBeDamaged(clerk, false)
		SetPedCombatAttributes(clerk, 46, true)                     
		SetPedFleeAttributes(clerk, 0, 0)      
		SetEntityInvincible(clerk, true)                
		SetBlockingOfNonTemporaryEvents(clerk, true)
		Wait(500)
		FreezeEntityPosition(clerk, true)
	
		SetNetworkIdCanMigrate(PedToNet(clerk), true)

		DecorSetBool(clerk, "isRobbable", true)
		DecorSetBool(clerk, "storerobbery", true)

		table.insert(networkedClerks, {
			["store"] = store,
			["clerk"] = PedToNet(clerk)
		})

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