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?
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