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

I need help with a broken teleportation script mi doing something wrong?

Asked by 5 years ago

So im trying to make a door that will teleport you useing a key but i realized that i have no idea how to do that here is the script i used

script.Parent.Touched.Connect(function(hit) if hit.Parent.Name == "Orange Key" then script.Parent.Touched:Connect(function(hit) if hit.Parent.Name == "Orangekey" then script.Parent.CanCollide =true db=false script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player=game.Players:GetPlayerFromCharacter(hit.Parent) if db==false then db=true script.Parent.BrickColor=BrickColor.new("Bright red") player.leaderstats.Cash.Value=player.leaderstats.Cash.Value-500 wait(3) script.Parent.BrickColor=BrickColor.new("bright green") db=false end end end)

function OnTouched (hit) local human=hit.Parent:FindFirstChild("Torso") local brick=script.Parent if (human ~=nil) then human.CFrame= CFrame.new(Vector3.new(70.672, 65.843, -152.176)) end end

script.Parent.Touched:Connect(OnTouched)

1 answer

Log in to vote
0
Answered by
brok4d 77
5 years ago

I had some errors more or less works teleports

script.Parent.Touched:Connect(function(hit) 

    if hit.Parent.Name == "Orange Key" then

        script.Parent.Touched:Connect(function(hit) 

            if hit.Parent.Name == "Orangekey" then

                script.Parent.CanCollide =true 
                db=false
            end 
        end)
    end
end)
script.Parent.Touched:Connect(function(hit) 

    if hit.Parent:FindFirstChild("Humanoid") then

        local player=game.Players:GetPlayerFromCharacter(hit.Parent) 
        if db==false then
            db=true 
            script.Parent.BrickColor=BrickColor.new("Bright red") 
            player.leaderstats.Cash.Value=player.leaderstats.Cash.Value-500 
            wait(3) 
            script.Parent.BrickColor=BrickColor.new("bright green") 
            db=false 
        end 
    end 
end)

function OnTouched(hit)
    local human=hit.Parent:FindFirstChild("Torso") 
    local brick=script.Parent 
    if (human ~=nil) then

        human.CFrame= CFrame.new(Vector3.new(70.672, 65.843, -152.176)) 
    end 
end 

script.Parent.Touched:Connect(OnTouched)
0
When you put code, give it to the blue ball and enter the code between brok4d 77 — 5y
Ad

Answer this question