Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Elevator button not working?

Asked by 8 years ago

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)
0
Edited. rexbit 707 — 8y
0
Edited[2] rexbit 707 — 8y

1 answer

Log in to vote
1
Answered by
rexbit 707 Moderation Voter
8 years ago

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)
0
This doesn't work and there is no errors in console. BennyBoiOriginal 293 — 8y
0
It is a LocalScript. BennyBoiOriginal 293 — 8y
1
Do switch to a normal script and try. rexbit 707 — 8y
Ad

Answer this question