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

How to make NPC that teleport to random locations selected by me?

Asked by 2 years ago

Hi, I'm trying to make a game like (The intruder) But I need to make a monster that teleports to random locations chosen by me. I don't know how to do it and there are no tutorials on YouTube. All I need is a script that I put into the NPC and right after the game starts it will be teleported to random locations for a limited time. (For example: NPC will be teleported to part1 then to part4 and then to part 9) Because i have cameras like in FNAF... :D

Thank you for help.

Rohlik1234567890

1 answer

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

Next time put your attempts here first, but here you go anways put invisible parts around the workspace and name them part1 part2 etc...

script in serverscriptservice --its not in the npc hope you dont mind

local npc = game.Workspace.NPC --replace this with your npc
local part1 = game.Workspace.Part1
local part2 = game.Workspace.Part2
local part3 = game.Workspace.Part3
--make variables for the rest of the parts
local PartToTeleport

while true do
wait(4) --will make it wait 4 seconds before teleporting again, change as you wish
PartToTeleport = math.random(1,3) --replace 3 with the amount of parts
if PartToTeleport == 1 then
npc.HumanoidRootPart.CFrame = part1.CFrame

elseif PartToTeleport == 2 then
npc.HumanoidRootPart.CFrame = part2.CFrame

elseif PartToTeleport == 3 then
npc.HumanoidRootPart.CFrame = part3.CFrame
--continue like this down for all parts
end
end

and that should do it hope this helped

0
Output says: ServerScriptService.Script: 20: Expected 'end' (to close 'do' at line 8), got <eof>; did you forget to close 'then' at line 17? I don't know why I did everything right ... oldmantv12345 9 — 2y
0
If I do the end command under line 17, the script works for me, but the NPC only teleports and still to one location. oldmantv12345 9 — 2y
0
sorry about that last end but also do you have everypart because i tried this myself and it worked, make sure every variable is correct. super00rocket 27 — 2y
0
Oh its working now :D Thank you oldmantv12345 9 — 2y
0
np! super00rocket 27 — 2y
Ad

Answer this question