So I am trying to make a player teleport when they pick a certain choice in a dialog choice. Here is my code:
local Dialog = script.Parent.Parent
local DC1 = Dialog.Dialogpart.DialogChoice1
local DC2 = Dialog.Dialogpart.DialogChoice2
Dialog.DialogChoiceSelected:connect(function(player,choice)
if choice == DC1 then
local humanoid = player.Character:FindFirstChild("Humanoid")
if humanoid ~= nil then
humanoid.Torso.CFrame = CFrame.new(-705.6, 8.319, 141.9)
end
end
end)
It comes up with this error: 12:56:42.868 Dialogpart is not a valid member of Dialog "Workspace.Centurion.Head.Dialog" - Server - Script:2
The script is a server script inside of the dialog choice.
didn’t work. It gives me this error now: 13:16:09.693 DialogChoice1 is not a valid member of Dialog "Workspace.Centurion.Head.Dialog" - Server - Script:2
There is no more error but it is not teleporting still. The code that I am using to teleport the player works and I have used it in other games before.
Sorry, I didn’t read the question properly… If it doesn’t come up with any errors, you can try using print statements to detect how far the code runs and figure out the issue based on where it stops, like this:
Dialog.DialogChoiceSelected:Connect(function(player, choice)
print(choice + " was selected")
if choice == DC1 then
print("DC1 was selected")
local humanoid = player.Character:FindFirstChild("Humanoid")
if humanoid ~= nil then
print("Humanoid detected")
humanoid.Torso.CFrame = CFrame.new(-705.6, 8.319, 141.9)
print("Teleport not working?")
end
end
end)