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

How do I make an NPC/AI Teleport a player somewhere? (UNANSWERED)

Asked by 9 years ago

I've tried to teleport players with scripts, and I tried a GUI, but it doesn't correspond with the NPC. I need a way to make an npc teleport a player when they say a certain response. It has something to go with game.Workspace.NPC.Dialog.DialogChoice maybe? Idk I really need help it's for my game.

3 answers

Log in to vote
1
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
9 years ago

Here's a wiki article on how to use dialogs.

If you want to connect to a certain response, use DialogChoiceSelected and teleport the character when they choose a certain option.

0
So, what would the script for that be? NatharuReal 0 — 9y
0
Looking at that wiki article may help! Sharpthy 46 — 9y
0
I tried the wiki, it was way too co plex for me, I just started scripting :P NatharuReal 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Actually quite simple. (in my terms I guess. I've worked with this for a while now) So let's start with the function!

First we need to establish the directory to the dialog and add an argument. (player,choice) player being the player who clicked and choice being the dialog selected! Make sure that the directory is to the starting dialog and not its descendants!!!

game.Workspace.NPC.Head.Dialog.DialogChoiceSelected:connect(function(player,choice)--Change the directory to the NPC you want and then to the Dialog (Right before DialogChoiceSelected)

Now we need to add the code.

    if choice.Name == "ChoiceA" then --change ChoiceA to the choice you want to be activated to execute the code!

Now for the code!

NPC = game.Workspace.NPC--Change this to the directory of the npc you want teleported!

NPC:MoveTo(player.Character.Torso.Position)--this method establishes the position of the model!

The Finished script!!

game.Workspace.NPC.Head.Dialog.DialogChoiceSelected:connect(function(player,choice)
    if choice.Name == "ChoiceA" then
NPC = game.Workspace.NPC

NPC:MoveTo(player.Character.Torso.Position)
    end
end)

I tested this myself so it should work! Hope this helped!!! Accept the answer if it did!!

0
Can you dumb that down for me? xD NatharuReal 0 — 9y
2
Can you learn a bit more lua and come back? xD Sharpthy 46 — 9y
0
I just started scripting a few days ago. So, could you like, make the script out of my NPC and choices and such? I have 3 choices, I want choiceA to Teleport, and the NPC is named Krillin. If you could make the script with those, So I knew what you meant, then that would be a lot of help. NatharuReal 0 — 9y
Log in to vote
0
Answered by 9 years ago

First off, may I remind you this isn't a request site, but moving on: You first have to use DialogueChoiceSelected, then check to see if the choice you wanted them to select was selected, then use CFrame.new to move the torso of the player somewhere.

Answer this question