Can anyone tell me why this teleport script dosen't work?

Hi so I wanted to make a teleport script by a ui but it dosen’t work.

wait(0)
player = game.Players.LocalPlayer
button = script.Parent
local debounce = false

function teleport()
if not debounce then
debounce = true
LowerTors = player.Character.LowerTorso
LowerTors.CFrame = game.Workspace.Train1Seat.CFrame
end
end

button.MouseButton1Click:Connect(teleport)
while true do wait()
debounce = false
wait(0)
end

But it dosen’t work :frowning:

First of all, can you please make it so that we can read the code. Secondly, what is the error. This is the things that I hate to see when people is asking the community to solve problems without enough informations.

2 Likes

Okay, thx for reminding me! I will try again

Here you call the teleport in the click, I don’t suggest that, instead call it like this


button.MouseButton1Click:Connect()
teleport()
while true do wait()
debounce = false
wait(0)
end

Okay Thanks! I will try this code now

Also, why are you teleporting the lower torso via CFrame? Teleport the HumanoidRootPart

1 Like

Your getting this error I assume,

[invalid argument #3 (CFrame expected, got Instance)](rbxopenscript://www.dummy.com/dummy?scriptGuid=%7B48A62C80-FC99-45C1-8BB3-8B8E2F5B6A2C%7D&gst=2#10)

I got this kind of error “Seat1 is not a valid member of workspace”

Then make sure it’s in the location you set it to.

1 Like

Im not sure if this is going to work.

button = script.Parent
player = button.Parent.Parent.Parent
local debounce = false

function teleport()
    if debounce ~= true then
        debounce = true
        player.Character:MoveTo(Vector3) --Replace vector3 with the position of your train seat
    end
end

button.MouseButton1Click:Connect(teleport)
    teleport()
end

while true do
    if debounce == false then
        wait(0.05)
        debounce = true
    end
end
1 Like
wait(0)
player = game.Players.LocalPlayer
button = script.Parent
local debounce = false

function teleport()
	if not debounce then
		debounce = true
		player.Character.HumanoidRootPart.CFrame = workspace.Train1Seat.CFrame
	end
end

button.MouseButton1Click:Connect(teleport)
while true do wait()
	debounce = false
	wait(0)
end
1 Like

This works, just make sure Train1Seat is in workspace.

1 Like

Okay Thanks! I will try it :smiley:

Okay I will try this too! :smiley:

The script works now, So the reason was the part wasn’t in the workspace but in a model. Im dumb but anyway thanks for the help everyone! :smiley: