Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Elevator button not working?

I am making an elevator and when a player clicks a button it teleports them but it doesn't work. There are no errors in the output.

Script:

wait(1)

player = game.Players.LocalPlayer

function teleport()
	torso = player.Character.Torso
	torso.CFrame = CFrame.new(game.Workspace.Floor2Ele.Part.CFrame)
end

script.Parent.ClickDetector.MouseClick:connect(teleport)

2 comments

0

Edited.

0

Edited[2]

1 answer

✓ Accepted answer

One easier way is the usage of MoveTo.

wait(1)

player = game.Players.LocalPlayer

function teleport()
    local c = player.Character
    c:MoveTo(workspace.Floor2Ele.Part.Position)
end

script.Parent.ClickDetector.MouseClick:connect(teleport)

The problem with using CFrame is unanimous to me, although I can recall some occurrences.

Edited Section

I realized that you didn't clarify if the syntax was either located in a script or localscript. If it was script then here's the right syntax.


function teleport(player)
    local c = player.Character
    c:MoveTo(workspace.Floor2Ele.Part.Position)
end

script.Parent.ClickDetector.MouseClick:connect(teleport)

3 comments

0

This doesn't work and there is no errors in console.

0

It is a LocalScript.

1

Do switch to a normal script and try.

This discussion is preserved as it was. New answers, comments, and votes are closed.