How to fix the fall of server-sided NPC through terrain/models created by client side

local maxCopies = 10
local cooldown = 5

local npcModel = game.ReplicatedStorage.NpcModel

local modelQueue = {}

local function createNPC()
	local player = game.Players.LocalPlayer

	local character = player.Character or player.CharacterAdded:wait()
	local playerPosition = character:WaitForChild("HumanoidRootPart").Position
	if playerPosition then
		local radius = 50
		local minDistance = 25
		local randomOffset = (Vector3.new(math.random(), 0, math.random()) - Vector3.new(0.5, 0, 0.5)).unit * (radius + minDistance)
		local npcPosition = playerPosition + randomOffset

		local newNPC = npcModel:Clone()
		newNPC:SetPrimaryPartCFrame(CFrame.new(npcPosition))
		newNPC.Parent = game.Workspace

		table.insert(modelQueue, newNPC)

		if #modelQueue > maxCopies then
			local oldestNPC = table.remove(modelQueue, 1)
			oldestNPC:Destroy()
		end
	end

end

while true do
	createNPC()
	wait(cooldown)
end

This script should work, i just tested but it only spawns the npc’s. you need another script in the Npc to chase the player and attack.

I’m temporarily using Drooling Zombie which has a chase script, but for some reason, it doesn’t work. You can try to check for yourself

I just had a look and it works, make sure the primary part of the model is set to HumanoidRootPart and make sure both scripts the One named “Script” and the “Animate” is set to client in properties.

I checked it out and it does work. Thank you! I think I can close the post

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