Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make a part a spawner?

Asked by
R_ngar 10
6 years ago

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?

0
set the HumanoidRootPart CFrame of the NPC to the part's CFrame User#23365 30 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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
0
thank you so much! R_ngar 10 — 6y
Ad

Answer this question