I made a door script which works and everything, but when a player opens the door, the sound the door plays, plays for everyone in the server, even if they’re across the map.
How would I make it so that only the player that opened the door can be the only player to hear the door sound or at least have it be a proximity sound so someone that isn’t across the map can’t hear it.
local TweenService = game:GetService("TweenService")
local door = script.Parent
local doorHinge = door.PrimaryPart
local doorOpen = TweenInfo.new()
local doorCFrame = TweenService:Create(doorHinge, doorOpen, {
CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(-90),0)
})
local doorCFrameClosed = TweenService:Create(doorHinge, doorOpen, {
CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(0),0)
})
local ProximityPrompt = script.Parent.ProximityPrompt
local PromptVanish = ProximityPrompt.Enabled == false
local PromptAppear = ProximityPrompt.Enabled == true
ProximityPrompt.Triggered:Connect(function()
doorCFrame:Play()
ProximityPrompt.Enabled = false
script.Parent.Open:Play()
wait(0.95) --Door Stays Open this long
doorCFrameClosed:Play()
ProximityPrompt.Enabled = true
wait(1)
script.Parent.Close:Play()
end)
If anyone can help, that would be great.
P.S. Thank you to everyone who replied to the post and helped out. It really means a lot especially because I am a fairly new developer and I’m glad that the DevForum is really helpful and supportive. Thank you.
ok i figured it out, you might want to parent the sounds to a part in your door (example: Hinge) and then play the sounds that are inside the part, since you have the sounds in the model they will play globally, hope this helps!
ok i figured it out, you might want to parent the sounds to a part in your door (example: Hinge) and then play the sounds that are inside the part, since you have the sounds in the model they will play globally, hope this helps!