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)
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)