Right now I have a local script in StarterPlayerScripts and a script in ServerScriptService. I have one remote event in replicatedStorage called PlaySoundInteraction. I have three parts in workspace. Each part has a proximity prompt and a sound parented to the part. I am trying to make it where when a player interacts with any of the three proximity prompts, the PlaySoundInteraction will be fired. It will be fired and connected to the script in ServerScriptService. It will then initialize a function in that script which basically plays the sound in the part that had the proximity prompt that was interacted with.
What is the error?
Sound is not playing when player interacts with anyone of the proximity prompts.
Here is what I have have right now but does not exactly work.
Local script in StarterPlayerScripts.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EnableInteraction = ReplicatedStorage:WaitForChild("EnableInteraction")
local function onPromptTriggered(prompt)
local part = prompt.Parent
EnableInteraction:FireServer(part.Name)
end
-- Connect to the ProximityPrompt's Triggered event
local lockerPrompt = game.Workspace.LockerInteract.ProximityPrompt
lockerPrompt.Triggered:Connect(onPromptTriggered)
local garbageBagPrompt = workspace.GarbageBagInteract.ProximityPrompt
garbageBagPrompt.Triggered:Connect(onPromptTriggered)
local ventPrompt = workspace.VentInteract.ProximityPrompt
ventPrompt.Triggered:Connect(onPromptTriggered)
Script in ServerScriptService.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EnableInteraction = ReplicatedStorage:WaitForChild("EnableInteraction")
local function initializeInteraction(player, partName)
local part = workspace:FindFirstChild(partName)
local sound = part:FindFirstChild("Sound")
if sound and sound:IsA("Sound") then
sound:Play()
end
end
-- Listen to the remote event
EnableInteraction.OnServerEvent:Connect(initializeInteraction)
And then of course I have a remoteFunction in ReplicatedStorage. Thank you.