local enabled = true

function onTouched(human)
	print("Touched")
	local touchpart = script.Parent
	local door = script.Parent.Parent.Door
	local h = human.Parent:FindFirstChildWhichIsA("Humanoid")
	if h and enabled then
		enabled = false
		print(1)
		door.BodyPosition.Position = script.Parent.Parent.End.Position
		wait(3)
		door.BodyPosition.Position = script.Parent.Parent.Start.Position
		enabled = true
		wait(1)
		print("Done")
	end
end

script.Parent.Touched:Connect(onTouched)

I put this script into the part that the player touches. When I run the game, the brick goes to position 0,0,0. (Prints are just there to try to pinpoint problem) What's wrong with it?

2 comments

0

You shouldn’t use FindFirstChildWhichIsA, use FindFirstChildOfClass.

0

Have the print statements pinpointed the problem? Also, you should check script.Parent.Parent.End.Position and .Start.Position. And use :WaitForChild() or :FindFirstChild() to make sure you're not indexing something that doesn't exist.