Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

1 comment

0

When you put code, give it to the blue ball and enter the code between

This discussion is preserved as it was. New answers, comments, and votes are closed.