Teleporting player in local script

More than two weeks ago, I tried to make a script whose task was to teleport the player who was activating ProximityPromt.

The task seemed simple as I usually do. Unfortunately, nothing worked in this case. There was also no error on the console.

Explorer photo

Local script
	local Players = game:GetService("Players") 
	local Player = Players.LocalPlayer
	local Character = Player.Character or Player.CharacterAdded:Wait()

I tried to fix everything from moving the script to server script and ending with a complete script change. Neither of these actions worked or generated further errors.

I also asked people on the dev forum, but they didn’t tell me anything specific, just asked to send the entire script, or they wrote the script from scratch, completely out of context, e.g. adding debounce, changing ProximityPromt to a UI button or something like that.

I’ve already done a similar script in the GUI and it worked without a problem. Now, however, difficulties have arisen.

maybe this? I am still pondering my coding skills but this may help.

local Teleport = "part"
function Touch(hit)
	if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true
	local Pos = script.Parent.Parent:findFirstChild(Teleport)
		hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end 

The problem is that you have your LocalScript in workspace wich you shouldn’t because LocalScripts are client side

to fix that replace it with a Script

The Script

local prompt = script.Parent.ProximityPrompt

    local character = player.Character or player.CharacterAdded:Wait()

I do not think you can use ProximityPrompt with a local script its better to use a normal script.

I changed it to server script but the error “12:49:27.792 Workspace.Room.Door.Union.Script:4: attempt to index nil with ‘Character’” popped out

Try this

local Prompt = script.Parent.ProximityPrompt

    local character = player.Character or player.CharacterAdded:Wait()
    character.HumanoidRootPart.CFrame =

Prompts work in local scripts, you just have to make sure that whomever triggers it matches the player of which the local script is executing for.

local Script = script
local Workspace = workspace
local Part = Script.Parent
local Prompt = Part.ProximityPrompt
local Teleport = Workspace.LeaveHouseTeleport

local function OnPromptTriggered(Player)
	local Character = Player.Character
	if not Character then return end