Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ProximityPrompt Teleportation not working as intended?

Hey, I'm trying to make a set of stairs that teleport to eachother when you use them. When I first put a script in, it worked, but you could hold you any amount of time and it worked. I had been requested by another developer to make sure it is after the delay, so I changed it a little, but nothing happened no matter how long you hold.

local prox = game:GetService("ProximityPromptService")

local function onPromptTriggered(promptObject, player)
	if promptObject == script.Parent then
		local chr = player.Character
		if chr then
			local humroot = chr:FindFirstChild("HumanoidRootPart")
			if humroot then
				humroot.Position = Vector3.new(313.25, -580.087, -267.5)
			end
		end
	end
end

prox.PromptTriggered:Connect(onPromptTriggered)

The method that worked but not as expected utilized PromptButtonHoldEnded().

Any way anyone can help this?

1 comment

0

Prompt triggered works when hold duration is 0

1 answer

Use ProximityPrompt.Triggered instead

local prox = script.Parent -- change to the proximity prompt object

local function onTriggered(player)
        local chr = player.Character
        if chr then
            local humroot = chr:FindFirstChild("HumanoidRootPart")
            if humroot then
                humroot.Position = Vector3.new(313.25, -580.087, -267.5)
            end
        end
end

prox.Triggered:Connect(onTriggered)

This discussion is preserved as it was. New answers, comments, and votes are closed.