Hello guys! So I am trying to make a RPG game with NPCs. NPCs are supposed to spawn in a certain area, but I want to do the spawner this way: Take a part, and make NPCs only spawn inside the part, like only in the area the part is. How should I do that?
✓ ANSWER ACCEPTED
How to make a part a spawner?
1 answer
✓ Accepted answer
you'd set the HumanoidRootPart CFrame or just use :SetPrimaryPartCFrame() to move the NPC.
local NPC = workspace.NPC -- lets say this was the NPC
local spawnp = workspace.Spawn -- the spawn point
while true do
local clone = NPC:Clone()
clone:SetPrimaryPartCFrame(spawnp.CFrame) -- or you could use
--[[clone.HumanoidRootPart.CFrame = spawnp.CFrame]]--
clone.Parent = workspace
wait(10)
end
or if you wanted it to spawn in a certain radius around the part you can do this
clone:SetPrimaryPartCFrame(spawnp.CFrame + Vector3.new(math.random(-10,10), 0, math.random(-10,10))) -- 20x20 square radius around the spawn
1 comment
0
thank you so much!
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
set the HumanoidRootPart CFrame of the NPC to the part's CFrame