How do I detect if a ProximityPrompt is used twice?

I was wondering how to do this so I can make a door.
When they press it once, they go to point a, when they press it again, they go to point b.
I have the code for part a but I do not know how to make it detect if it’s clicked once more

1 Like
local active = 0
prompt.Triggered:Connect(function()

    if active == 0 then
        active = 1
        // code
    elseif active == 1 then
        active = 0
        // code
    end

end)
2 Likes

I’m getting this error
Workspace.Handle.ProximityPrompt.Script:11: attempt to index nil with 'Humanoid’
Here’s the code:

local Prompt = script.Parent
local player = game.Players.LocalPlayer
local active = 0

Prompt.Triggered:Connect(function()
	if active == 0 then
		active = 1
		player.Humanoid:MoveTo(Vector3.new(18.426, 8.146, 36.175))
	elseif active == 1 then
		active = 0
		player.Humanoid:MoveTo(Vector3.new(16.437, 7.206, 28.312))
	end

end)

I have tried Character instead of Humanoid but that doesn’t work

instead of local player = game.Players.LocalPlayer try this script:

game.Players.PlayerAdded:Connect(function(player)
local Prompt = script.Parent
local active = 0

Prompt.Triggered:Connect(function()
	if active == 0 then
		active = 1
		player.Humanoid:MoveTo(Vector3.new(18.426, 8.146, 36.175))
	elseif active == 1 then
		active = 0
		player.Humanoid:MoveTo(Vector3.new(16.437, 7.206, 28.312))
	 end
  end)
end)

Your answer fixed it, I just made the mistake as well “Humanoid” instead of Character.

umm… you made your reply a solution and not my reply to your original post. i would like the solution sir or maam