So I have this ProximityPrompt door here, and inside of the script, code to make sounds play once the player opens the door. The only issue is that it plays for the entire Server, and not just for the person that is opening the door.
Here’s the script:
local Hinge = script.Parent.PrimaryPart
local opened = false
local Promt = script.Parent:WaitForChild("ProximityPrompt")
local sound = script.DoorOpen
local closingsound = script.DoorClose
if opened == false then
opened = true
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(4.3), 0))
opened = false
for i = 1, 21 do
script.Parent:SetPrimaryPartCFrame(Hinge.CFrame*CFrame.Angles(0, math.rad(-4.3), 0))
Considering the door is a server created object, you should be able to access the sounds from a client script.
The problem is to know ‘when’ to play the sound and when to stop it.
You can use a RemoteEvent to tell the client to play a sound, and even give it the Instaces of the sounds to play
So maybe just make a local script called ‘sound player’ and it looks for events from the server, with a remote event, that tells it to either play a sound or stop a sound, and the instances of the sounds. Keep the playing sounds in a table keyed by the sound id, and so you can easily find the sound to stop it playing
When a sound’s parent is a Part, then it’ll play on that part. If it’s in somewhere like a Script, then it’ll play globally.
What you’re gonna want to do is put the sounds in one of the parts in the door (the door part that moves would be more suitable), then play the sounds, since that’s the easiest solution.