So, I'm trying to make a script where a character progressively gets closer to the player and eventually killing them. However, I want the player to be able to reset the character by pressing a button. This is the code I have so far.


 local SUNFI5H = script.Parent

local humanoid = SUNFI5H.Humanoid

local button = game.Workspace.door.duckbutton

while true do

	wait(13)

	humanoid:MoveTo(workspace.waypoints4.d1.Position)

	humanoid.MoveToFinished:Wait()

	wait(8)

	humanoid:MoveTo(workspace.waypoints4.d2.Position)

	humanoid.MoveToFinished:Wait()

	wait(8)

	humanoid:MoveTo(workspace.waypoints4.d3.Position)

	humanoid.MoveToFinished:Wait()

	wait(10)

	humanoid:MoveTo(workspace.waypoints4.d4.Position)

	humanoid.MoveToFinished:Wait()

end

button.ClickDetector.MouseClick:Connect(function()

	humanoid:MoveTo(workspace.waypoints4.d0.Position)

	humanoid.MoveToFinished:Wait()

end)