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

how to make a script that teleports all the same npcs in the workspace to me?

Asked by 4 years ago

Example there are 20 Zombies, 10 Skeletons how can i make a script that teleports all 20 Zombies and 10 Skeletons to me, please provide a script and tell me what each line of script does please.

1 answer

Log in to vote
0
Answered by 4 years ago

Loop through workspace, check if its an npc and tp it to you

Use this:

local location = workspace -- modify to the npcs parent if needed
local player = game.Players.TARGETMODIFY

for i, v in pairs(location:GetChildren()) do
    if v:FindFirstChild("Humanoid") then
        v.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame
    end
end
Ad

Answer this question