Why doesn't this teleport script work?

I want to teleport the player when they click “Yes” in the dialog choice

local Dialog = script.Parent
Dialog.DialogChoiceSelected:Connect(function(player, choice)
	if choice.Name == "Yes" then
		player.Character.HumanoidRootPart.CFrame = World2StartingPoint.CFrame
	end
end)

This is the dialog, If you need more info/screenshots I will edit this post.
fjvjkisfhvksfhvnsjfbv

2 Likes

What Error you get when you test it?

The thing is, I don’t get an error, it just doesn’t work.

I think you need to have the “c” in “connect” to be capitalized. But I could be wrong

Try this:

local Dialog = script.Parent
Dialog.DialogChoiceSelected:Connect(function(player, choice)
	if choice.Name == "Yes" then
		player.Character.HumanoidRootPart.CFrame = World2StartingPoint.CFrame
	end
end)

I capitalized it but it still does not work

This method works in LocalScripts. Move your code to a LocalScript and use remotes for it to teleport the player on the server.

The code seems good, also try to print the player.name and choice.name to see if it starts or as @raid6n said try use a LocalScript

Dialog | Documentation - Roblox Creator Hub Dialog wiki if you need

Tried that, didn’t work

So if you print(player.name) what does it print? If it prints nothing, it is probably the script, not a glitch.

It prints nothing

Why is nobody replying anymore this still isn’t solved?

still doesn’t work huh?

have you did this

player.Character:MoveTo(World2StartingPoint.Position, World2StartingPoint)
script.Parent.DialogChoice.DialogChoiceSelected:Connect(function(player, choice)
if (choice == script.Parent.Yes) then
local HumanoidRootPart = player.Character:WaitForChild("HumanoidRootPart")
if HumanoidRootPart then
player.Character.HumanoidRootPart.CFrame = World2StartingPoint.CFrame -- You can use other alternative ways to teleport them.
print("teleported")
  end
   end
end)

does dialog choice selected event has player on the first parameter tho?

Yes, still doesn’t work

What do you mean? Could you elaborate

try printing anything inside the if statement if it doesnt print then its the bug

does the event conclude player as the first parameter?

I know from personal experience that this is an outdated feature and a pain to work with I would recommenced making your own chat system. But if you truly most use this feature put a local script inside of StarterPlayerScripts. Then you have to mention everything from there.

local Dialog = game.Workspace.NPC.Head["Teleport To World 2?"]
Dialog.DialogChoiceSelected:Connect(function(player, DialogChosen)
	if DialogChosen.UserDialog == "Yes" then
		player.Character:MoveTo(World2StartingPoint.Position)
	end
end)

Make sure the code is in starterplayerscripts

I’m not sure what you mean. DialogChoiceSelected holds two arguements. The player object and and the object of the choice the player selects. The function doesn’t return the name of the choice, but fires when the player selects a choice. See