Proximity Prompt not working

This code works 50% percent of the time sometimes it does sometimes it doesn’t and it seems restarting the game fixes it.

It’s supposed to show a ScreenGui so would really appreciate it if anyone could help me.

local PromixyPrompt = game.Workspace.GunDealer.PromptPart.ProximityPrompt
local ProximityPromptService = game:GetService(“ProximityPromptService”)

PromixyPrompt.Triggered:Connect(function()
script.Parent.Enabled = true
script.Interact:Play()
end)

3 Likes

Here’s video showcasing the script not functioning

is it on the client side of the sever expmaple is the script icon white or blue

Its a local script so client sided

So it might be the promixty prompt hasn’t be replicated to the client i suggest to either addibg a task.wait(1) ir use :waitforchild but task.wait is better because it will not yeild

Task.wait must be at the top of the script

1 Like

Hi!

Local scripts do not work in workspaces. Replace the local script with a script and copy the local script’s code to the script.

ProximityPrompt also has it’s Player variable in the triggered event. You can use the Player variable to show the ScreenGui or you could make a remote event that has it’s StarterPlayerScripts LocalScript and fire it when the proximity prompt is triggered.

Hope this helps! Bye!

1 Like

The local script is inside of screengui

Can we see your explorer? Do you happen to have another object named ProximityPrompt in the PromptPart? There’s a possibility that you just duplicated the ProximityPrompt instance and the ProximityPrompt variable in your code is choosing one of the two, which would explain why it only works some of the times.

Didn’t workㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ

Screenshot 2025-01-18 153800
Screenshot 2025-01-18 153820

@MrNobodyDev might be correct, try something like this

local PromixyPrompt = workspace:WaitForChild("GunDealer"):WaitForChild("PromptPart"):WaitForChild("ProximityPrompt")
local ProximityPromptService = game:GetService(“ProximityPromptService”)

PromixyPrompt.Triggered:Connect(function()
	script.Parent.Enabled = true
	script.Interact:Play()
end)```
1 Like

Awh man thank you so much seems to be working much more consistently now thank you.

1 Like

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