Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a part a spawner?

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?

1 comment

0

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

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.