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

How do I make the player or client teleport?

Asked by 5 years ago
Edited 5 years ago
teleportpositon = CFrame.new(241.999, 43,607, 318)
script.Parent.ClickDetector.MouseClick:Connect(function(player)
wait (5)
script.Parent.Parent.Model.PART1.CanCollide = true
    script.Parent.Parent.Model.Part.CanCollide = true
    print ("elevator going up")
        if game.Workspace[player.Name]:FindFirstChild("Humanoid") then 
        playerWhoClicked.parent.HumanoidRootPart.CFrame = teleportpositon
        end
end)

I would like to make an elevator but it won't work can you help?

0
The PlayerWhoClicked is already set to the character. On line 08, remove the .Parent after PlayerWhoClicked Despayr 505 — 5y

2 answers

Log in to vote
-1
Answered by
Despayr 505 Moderation Voter
5 years ago

Mistake 1: You passed the player through the function, but used a different variable to reference the player. On line 2, the variable is called "Player", but on line 8, you use "PlayerWhoClicked"

Mistake 2: You tried finding the HumanoidRootPart in the PlayerFolder on line 8. A ClickDetector passes the Player in the PlayerFolder. You tried finding the parent of said player.

local teleportpositon = 241.999, 43,607, 318

script.Parent.ClickDetector.MouseClick:Connect(function(playerWhoClicked)

    wait (5)
    script.Parent.Parent.Model.PART1.CanCollide = true
    script.Parent.Parent.Model.Part.CanCollide = true
    print ("elevator going up")
    if playerWhoClicked.Character:FindFirstChild("Humanoid") then
        playerWhoClicked.Character:MoveTo(Vector3.new(teleportpositon))
    end
end)
0
Can i use CFrame turquoise_monkeyman 32 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I think nothings happening because of the weird CFrame at the top.

I think you accidentally put a , instead of a . when making the CFrame.

I think you could just change it to

CFrame.new(242, 43.5, 318)

and it would work.

0
what line turquoise_monkeyman 32 — 5y
0
The first one ihatecars100 502 — 5y

Answer this question