Proximity Prompt PC Interaction Error

Hi there, I’m quite a decent scripter and have somewhat 4 months of knowledge, (even though started it 4-5 years ago , _,) and I was kind of confused when I got this error.

I definitely won’t find anything on internet so this is the only place left to seek support in.

I’m making Sliding Tech Doors in my game that have Custom design. Here’s the code:

-- Services
local TweenService = game:GetService("TweenService")

local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Hirearchy
local LeftDoor = script.Parent.LeftDoor.DoorBlock
local RightDoor = script.Parent.RightDoor.DoorBlock

local button_front = script.Parent.Button_Front
local button_back = script.Parent.Button_Back

-- Positions
local Position_Initial_Right_Door = RightDoor.Position
local Position_Initial_Left_Door = LeftDoor.Position

local Position_Final_Right_Door = RightDoor.Parent.Pos_Final.Position
local Position_Final_Left_Door = LeftDoor.Parent.Pos_Final.Position

-- Tweens
local OpenTween_Left   = TweenService:Create(LeftDoor, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, .2), {Position=Position_Final_Left_Door})
local OpenTween_Right  = TweenService:Create(RightDoor, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, .2), {Position=Position_Final_Right_Door})
local CloseTween_Left  = TweenService:Create(LeftDoor, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, .2), {Position=Position_Initial_Left_Door})
local CloseTween_Right = TweenService:Create(RightDoor, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, .2), {Position=Position_Initial_Right_Door})

-- Other
local closed : boolean = true
local debounce = false

-- Remote Events
local CustomProximityPress = ReplicatedStorage:WaitForChild("Remote Events"):WaitForChild("CustomProximityPress")

local function doorToggle(button)
	print(button)
	if debounce == true then return end
	debounce = true
	button.ProximityPrompt.Enabled = false

	if closed then
		closed = false

		CloseTween_Left:Pause()
		CloseTween_Right:Pause()

		OpenTween_Left:Play()
		OpenTween_Right:Play()

		OpenTween_Left.Completed:Connect(function()
			debounce = false
			button.ProximityPrompt.Enabled = true

			button_front.ProximityPrompt.ActionText = "Close"
			button_back.ProximityPrompt.ActionText = "Close"
		end)
	else
		closed = true
		OpenTween_Left:Pause()
		OpenTween_Right:Pause()

		CloseTween_Left:Play()
		CloseTween_Right:Play()

		CloseTween_Left.Completed:Connect(function()
			debounce = false
			button.ProximityPrompt.Enabled = true

			button_front.ProximityPrompt.ActionText = "Open"
			button_back.ProximityPrompt.ActionText = "Open"
		end)
	end
end

for i, button : Part in script.Parent:GetChildren() do
	if button:HasTag("Button") then
		button.ProximityPrompt.Triggered:Connect(doorToggle, button)
		
		CustomProximityPress.OnServerEvent:Connect(function(plr, promptInstance)
			if promptInstance == button.ProximityPrompt then
				doorToggle(button)
			end
		end)
	end
end

Line 77 is intended for mobile users, it works perfectly fine. The error I get is, interestingly, on pc users. When I press on the door’s ProximityPrompt UI, it works. But when I press ( E ), it gives error:
“ProximityPrompt is not a valid member of Player “Players.MenderZN” - Server - Door Script:37”

Error originates at this moment: button.ProximityPrompt.Triggered:Connect(doorToggle, button)

2 Likes

Here is the issue:

		button.ProximityPrompt.Triggered:Connect(doorToggle, button)

You can’t add arguments to this type of connect function.

Fix:

		button.ProximityPrompt.Triggered:Connect(function()
			doorToggle(button)
		end)

This is not possible

3 Likes

Alright then, I guess that’s the only option. Thanks

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.