Why is this script for dialog not working

I am trying to print the player name and the choice name. There is no errors.
I found this code on the Roblox DevHub



script.Parent.Dialog.DialogChoiceSelected:Connect(function(player,choice)
	
		print(player.Name,choice.Name)
	
end)

You should use GetPropertyChangedSignal()

local Dialog = workspace:WaitForChild("Dummy"):WaitForChild("Head"):WaitForChild("Dialog")
local Player = game.Players.LocalPlayer

Dialog:GetPropertyChangedSignal("InUse"):Connect(function()
	print(Player.Name.." is using dialog!")
end)

Edit: It should be a local script inside starterplayerscripts

Is there is a way to check if the player selected a certain message to teleport them somewhere if they chose the right message?