Proximity prompt not working

Hi, when I click the prompt nothing is printed.

local ProximityPromptService = game:GetService("ProximityPromptService")
local function onPromptTriggered(promptObject, player)
	print("Triggered")
	if player == script.Parent.Parent.Parent.Parent.Owner then
		print("Hopefully triggered")
		seat:Sit(player.Character.Humanoid)
		print("Smth not working")
	end
end
ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)

You are probably using a local script. It must be a regular script.

3 Likes

His code works fine, I just tested it. ProximtyPromptService is this.

1 Like

It is a regular script (for word count)

1 Like

First off, where did you get the name ‘Proximity Prompt Service’ that doesn’t exist last time I checked (it may now not sure).
Second, is this a server script, if not make it one

Third here’s code that actually exists:

local ProximityPrompt = <proximity>
local function onPromptTriggered(promptObject, player)
	print("Triggered")
	if player == script.Parent.Parent.Parent.Parent.Owner then
		print("Hopefully triggered")
		seat:Sit(player.Character.Humanoid)
		print("Smth not working")
	end
end
ProximityPrompt.Triggered:Connect(function(player)
         onPromptTriggered(prompt, player) 
end)

if you have questions don’t ask

2 Likes

This dude knows his stuff, Nice job @UsedSpxse

1 Like

If you have questions don’t ask me since I’m trying to do work*

2 Likes

Try:

Function onPromptTriggered()

not local

1 Like

I would not recommend using proximitypromptservice, Just use Prompt.Triggered. If you have to use it like that you will need to name prompts so as any prompt doesnt fire the function. Ensure you are doing this in a Server Script.

1 Like

I think he got it from here.

2 Likes

Alright 1 - Yes it may not be efficient but it would work
2 - I was not aware of that and had never heard of it
and 3 - The tone of this message seems a bit ‘rude’

2 Likes
local function onPromptTriggered(player)
	print("Triggered")
	if player == script.Parent.Parent.Parent.Parent.Owner then
		print("Hopefully triggered")
		seat:Sit(player.Character.Humanoid)
		print("Smth not working")
	end
end

for _, Prompt in ipairs(workspace:GetDescendants()) do
	if Prompt:IsA("ProximityPrompt") then
		Prompt.Triggered:Connect(onPromptTriggered)
	end
end
1 Like

Turns out a local variable at the very beginning was misdefined. Idk how I missed that. Fixed it and it works now. My bad, sorry. Thanks everyone for your input. Also, I didn’t realise there so many ways to do this. Understand it better now. Ty.

4 Likes