Problems with ProximityPrompts

I’ve been trying to create a simple elevator script using the new proximity prompts, though I’ve run in to some issues.

When changing the rootParts position all prompts seem to completely break.

I’ve stripped down my code to be as simple as possible and I still cannot see what the problem is. I have tested the same code in another place and it seemed to work fine.

Elevator Code

script.Parent.UpperShaft.Trigger.ProximityPrompt.Triggered:Connect(function(plr)
	plr.Character.HumanoidRootPart.Position = plr.Character.HumanoidRootPart.Position - Vector3.new(0, 24, 0)
end)

script.Parent.LowerShaft.Trigger.ProximityPrompt.Triggered:Connect(function(plr)
	plr.Character.HumanoidRootPart.Position = plr.Character.HumanoidRootPart.Position + Vector3.new(0, 24, 0)
end)

Door Script

local Tween = game:GetService("TweenService")

local D1 = script.Parent.Parent.Door1
local D2 = script.Parent.Parent.Door2
local Button = script.Parent

Button.ProximityPrompt.Triggered:Connect(function()
	Button.ProximityPrompt.Enabled = false
	Tween:Create(D1, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),{Position = D1.Position - D1.CFrame.LookVector*2}):Play()
	Tween:Create(D2, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),{Position = D2.Position + D2.CFrame.LookVector*2}):Play()
	Button.Sound:Play()
	wait(2)
	Tween:Create(D1, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),{Position = D1.Position +  D1.CFrame.LookVector*2}):Play()
	Tween:Create(D2, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),{Position = D2.Position - D2.CFrame.LookVector*2}):Play()
	Button.Sound:Play()
	wait(.5)
	Button.ProximityPrompt.Enabled = true
end)

try :Destroy() ing the proximity prompt and creating a new one.
EX:

local Tween = game:GetService("TweenService")

local D1 = script.Parent.Parent.Door1
local D2 = script.Parent.Parent.Door2
local Button = script.Parent

Button.ProximityPrompt.Triggered:Connect(function()
	Button.ProximityPrompt:Destroy()
	Tween:Create(D1, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),{Position = D1.Position - D1.CFrame.LookVector*2}):Play()
	Tween:Create(D2, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),{Position = D2.Position + D2.CFrame.LookVector*2}):Play()
	Button.Sound:Play()
	wait(2)
	Tween:Create(D1, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),{Position = D1.Position +  D1.CFrame.LookVector*2}):Play()
	Tween:Create(D2, TweenInfo.new(.5, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),{Position = D2.Position - D2.CFrame.LookVector*2}):Play()
	Button.Sound:Play()
	wait(.5)
	instance.new(ProximityPompt, Button)
end)

If I made a spelling mistake in my code, then sorry

Don’t use .Position to move Players.

To correctly teleport a player without killing them, you must use the CFrame property and use the CFrame data type instead.

4 Likes