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

How to make a player teleport to a different position? [closed]

Asked by 4 years ago
Edited 4 years ago

Let me explain, i want it so that when a player clicks a part they will be teleported to a different position and i dont know how to do it. (I know most basic to medium level code just not advanced or Cframe so i don't know how to do this) I don't know if it should be a local script or anything like that.. So plz help

Anytime i search it it just shows up with how to teleport players to a different game rather than different position which is why im asking here

Closed as Not Constructive by Leamir

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by 4 years ago

This script should work fine. Make sure there is a click detector in the brick you want to be able to be clicked on first, as well as to make sure the script's parent is the brick you want to be able to be clicked

function onClicked(player)
    player.Character.HumanoidRootPart.CFrame = CFrame.new(0,0,0) -- replace this with the location you want
end

  script.Parent.ClickDetector.MouseClick:connect(onClicked)
Ad
Log in to vote
0
Answered by 4 years ago

This method of teleporting players uses CFrame, but it's rather easy and simple. It uses SetPrimaryPartCFrame()

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()


-- Example of how to use SetPrimaryPartCFrame(). This will not work by just copying this script, you'll have to do it yourself!

ClickDetector.MouseClick:Connect(function()
    char:SetPrimaryPartCFrame(workspace.Part.CFrame) 
    -- change workspace.Part to any BasePart in workspace!
end)

Hope this helps! Be sure to accept this answer if this helped!