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

Button telport script to spawnpoint block?

Asked by 5 years ago

Im trying to figure out how to make a click telporter to telport to diffrent areas this is my script

01modelname="teleporter1b"
02 
03function onTouched(part)
04    if part.Parent ~= nil then
05    local h = part.Parent:findFirstChild("Humanoid")
06        if h~=nil then
07            local teleportfrom=script.Parent.Enabled.Value
08            if teleportfrom~=0 then
09                if h==humanoid then
10                return
11                end
12                local teleportto=script.Parent.Parent:findFirstChild(modelname)
13                if teleportto~=nil then
14                    local torso = h.Parent.Torso
15                    local location = {teleportto.Position}
View all 70 lines...
0
Ok I dont get why if you are just trying to teleport a player to a different location you did all of that, unless this is something else and I misunderstood something. If you are just trying to TP a player to a different location tell me so I could give you a proper answer. AntoninFearless 622 — 5y
0
oh and in line 47 is says local player = game.Players.children() instead of game.Players:GetChildren() maybe that would be an issue too AntoninFearless 622 — 5y
0
im trying to make a scirpt that when a button gets clicked it telports the player to a diffrent spawn block ill try that aj44000 2 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

If you want a player to click a part in order to teleport put a clickdetector inside of the part and a ServerScript and put in the following:

01local cd = script.Parent.ClickDetector
02local teleport = CFrame.new(71.4, 2.9, -69.4) -- This is the position they will teleport I advise putting it up above ground a little so they dont get stuck
03 
04cd.MouseClick:connect(function(clicked) --Clicked is the person who clicked it
05    local player = game.Players:FindFirstChild(clicked.Name) --We get the persons Username
06    if player ~= nil then --If the player is still there then
07        local humr = player.Character:FindFirstChild('HumanoidRootPart') --We get their humanoidrootpart
08        humr.CFrame = teleport --We teleport the player to the new position
09    end
10end)
0
thanks alot aj44000 2 — 5y
Ad

Answer this question