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

i want to make a teleporter that makes you teleport into a training area How Do I Do This?

Asked by
K_H0ck 4
6 years ago
Edited 6 years ago

i want to make a gui that you click and it makes you teleport into a battle area, i also want it so that when you die you teleport to the same area as you started before you battled. i have multiple sections to the training ground and i need it to teleport you to the same section as you were before you died

2 answers

Log in to vote
0
Answered by 6 years ago

Main Idea

What you want to do is make a gui to teleport a player to a position if they click it, and if they die, they teleport back to the lobby.

Getting Started

Checkpoint Script, this is what we will be doing first. We want to make it so if you step on a certain brick, or touch a certain brick you will save that as your spawn position.

Make a brick and put a script inside of it. The script should look something like this:

local spawn = script.Parent
spawn.Touched:connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
        if not checkpointData then
            checkpointData = Instance.new("Model", game.ServerStorage)
            checkpointData.Name = "CheckpointData"
        end

        local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
        if not checkpoint then
            checkpoint = Instance.new("ObjectValue", checkpointData)
            checkpoint.Name = tostring(player.userId)

            player.CharacterAdded:connect(function(character)
                wait()
                character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
            end)
        end

        checkpoint.Value = spawn
    end
end)

Now you have the check point system down, you want to teleport people if they click a button.

We will need to use a LocalScript inside of your TextButton We will be learning about CFrames and Vector3 today. CFrames and vector3 can work togethor to change the position of the person. If you wanted to change the position of a brick, the CFrame wouldnt be neccecary. But if you did this to a person:

game.Workspace.Player.Torso.Position = Vector3.new(0, 50, 0)

The torso would be away from the body, therefore killing the player, Think about it, who can survive without a chest?

so we will be using the CFrame function with the Vector3:

game.Workspace.Player.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(0, 50, 0))

but this wont work either. We need to move the player not a random person so we will be using LocalPlayer so we will make a function, lets begin.

This script goes inside the local script that is in the Text Button as Stated earlier.

function onClicked
game.Players.LocalPlayer.HumanoidRootPart.CFrame = CFrame.new(Vector3.new("cords you want to teleport to"))
end

script.Parent.MouseButton1Click:Connect(onClicked)
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

I could be able to make something like this for you.... just tell me how many sections does it have ?

PLEASE DON'T CLICK THE DOWNVOTE I ALREADY HAVE -6 REPUTATION HERE

0
it has 6 K_H0ck 4 — 6y

Answer this question