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.
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.
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!!
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.