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

Can I have help with my nooby teleport script?

Asked by 6 years ago
local entrance = script.Parent

function tpcave()
    local h = game.Workspace:FindFirstChild("Humanoid")
    local p = h.Parent
    local torso = p.Torso   
    local reciever = game.Workspace.Reciever

    torso.CFrame = CFrame.new(reciever.Position)
end

entrance.Touched:Connect(tpcave)

It's pretty nooby and I tried to make it based off of a few things I saw in a teleport model I found online. Every time I touch the entrance, though it won't teleport me. Can someone show me what I'm doing wrong?

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
-- *First, Get 2 different parts and put them to the location you want to teleport to*

-- *Also name both of the parts, "Telepad"*

-- *Insert a StringValue into both of the parts and change the value to one of them, "1" and the other one, "2"*

-- *Then, Add this script into both of the bricks.*


local Teleport_To_This_Tag = "1"    -- *Set this value to the value in the teleporter*

function findTele(tag) 
    local tele = nil 
    function scan(p) 
        for _,v in pairs(p:GetChildren()) do 
            if ((v.Name == "Telepad") and (v:FindFirstChild("Tag"))) then 
                if (v.Tag.Value == tag) then tele = v break end 
            end 
            if (#v:GetChildren() > 0) then scan(v) end 
        end 
    end 
    scan(game:service("Workspace")) 
    return tele 
end 

script.Parent.Touched:connect(function(h) 
    local p = game:service("Players"):GetPlayerFromCharacter(h.Parent) 
    if not (p) then return end 
    if (p:FindFirstChild("JustTeleported")) then return end 
    if not (findTele(Teleport_To_This_Tag)) then return end 
    local tele = findTele(Teleport_To_This_Tag) 
    if (tele) then 
        if (p.Character) then 
            p.Character:MoveTo(tele.CFrame.p+Vector3.new(0,3.25,0)) 
            local t = Instance.new("Weld") 
            t.Name = "JustTeleported" 
            t.Parent = p 
            delay(1.5,function() t:remove() end) 
        end 
    end 
end)
0
Whoops it's all bunched up together, Here, I'll fix it. LennonLight 95 — 6y
Ad

Answer this question