Trouble with Proximity Prompt

Hey developers, I am new to proximity prompt.
What I want it to do is when I am done holding the key that this function triggers which allows a part to fall and kill the character. For some reason it doesn’t work, anyone know why?

function onHit(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		game.Workspace.Anchor.Anchored = false
	end
end

ProximityPromptService.PromptTriggered:Connect(onHit)

Use .Triggered instead, that way once you are done it will do the action. Also, make sure you are calling the specific proximity prompt.

1 Like

The proximity prompt doesn’t pass a hit parameter. Instead, it passes a Player parameter. Do this:

function onTrigger(Player)
	if Player then
		game.Workspace.Anchor.Anchored = false
	end
end

ProximityPromptService.PromptTriggered:Connect(onTrigger)
1 Like

Thanks for the answer. It worked!

1 Like