All of this code is located in a LocalScript in ReplicatedFirst.

player = game.Players.LocalPlayer
teleporter = game.Workspace.Projects.Enterance.Teleporter
torso = player.Character.Torso

--function (teleport to a brick)
function Teleport_to_room()

	--Plays a soundfile located in workspace		
	teleporter.Part.Teleport_sound:Play()	
	
	--Disables the button
	teleporter.Part.ClickDetector.MaxActivationDistance = 0
	wait(0.8)			
	
	--Teleports the user to the brick's location
	torso.CFrame = game.Workspace.Teleport_test.CFrame
	
	--activates the button	
	teleporter.Part.ClickDetector.MaxActivationDistance = 16

	
end

game.Workspace.Projects.Enterance.Teleporter.Part.ClickDetector.MouseClick:connect(Teleport_to_room)

Thanks for the help!

2 comments

0

The problem is you're not waiting for things to load, like objects in workspace or the player's character.

0

How would I go about fixing that?