Does anyone know how to use proximity prompt with local script?

  1. I want use proximity prompt linked to a local script, but I’m having issues.

  2. Whenever I click on the proximity prompt I can’t find the printed word on the output tab.

  3. At the moment I haven’t figured out a solution and I’ve also checked on the forum but nothing yet.

local ProximityPrompt = script.Parent.Parent.Proximity.ProximityPrompt

ProximityPrompt.Triggered:Connect(function(player)
	print("test")
end)

Surely I’m missing something, I’m new to scripting and sorry if I’m probably asking a dumb question.

11 Likes

Proximity prompt is manually local I’m pretty sure

The script I made firstly was server side, but what I’d like to do is a proximity prompt that opens a GUI with TweenService, but the tween is laggy on server side, that’s why I’m trying to do it client side. I’d like also to add sounds for client only

when I try to execute this script it won’t work for some reasons

Try using a RemoteEvent at this line of code, then tween the Gui and play the sounds from the client.

ProximityPrompt.Triggered:Connect(function(player)
	game.ReplicatedStorage.RemoteEvent:FireClient(player)
end

Tried but didn’t work at all, tried putting “script.Sound:Play()” under the fireclient line but didn’t work…

LocalScripts do not run inside parts, they only run inside player characters, backpack, or playergui.

2 Likes

Then how could I play a sound locally via a script? I’ve tried with SoundService:PlayLocalSound but nothing.

You can fire a RemoteEvent to the client and in the LocalScript you simply play the sound.

Pretty much something like this should work:

local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteName")
local ProximityPrompt = ....... -- Path to the proximity prompt

ProximityPrompt.Triggered:Connect(function(player)
    Remote:FireClient(player)
end)

And in the localscript you should have something like this:

local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteName")
local Sound = ........ -- Path to the sound you want to play

Remote.OnclientEvent:Connect(function()
       Sound:Play()
end)
11 Likes

Try to place a localscript in StarterplayerScripts or StarterGui, wherever you please, use a RemoteEvent to be fired in the code I provided above in the server, pick up the RemoteEvent in the LocalScript and play the sound from there on.

Remember, localscripts can only be used in:
-StarterGui
-StarterPlayerScripts
-StarterCharacterScripts
-ReplicatedFirst

Let me know if you’re having any further trouble with this.

1 Like