roblox dev how to spawn npc with location code example

Example: roblox dev how to spawn npc with location

local JFKspaWn = game.ReplicatedStorage.Cloneables.JFK.HumanoidRootPart

local JFK = game.ReplicatedStorage.Cloneables.JFK

local SSAgentspaWn = game.ReplicatedStorage.Cloneables.SSAgent.HumanoidRootPart

local SSAgent = game.ReplicatedStorage.Cloneables.SSAgent

function SpawnNPCs()

local newJFK = JFK:Clone()

newJFK.Parent = workspace

newJFK:MoveTo(Vector3.new(-172.606, 0.673, 6.5))

local newSSAgent = SSAgent:Clone()

newSSAgent.Parent = workspace.WalkingSSAgentsSpawnable

newSSAgent:MoveTo(Vector3.new(-174.52, 2.433, 14.632))

end

function beginNPCs()

SpawnNPCs()

game.Workspace.BindableEvents.SSAgentWalkToward:Fire()

end

beginNPCs()

game.Workspace:WaitForChild("SpawnJFK").Event:Connect(function()

beginNPCs()

end)

Tags:

Lua Example