Well, im making a store, when you step on a Part, the shop opens and the walkspeed is set to 0. When the shop opens, one of the three sounds will play, the problem here is: The sounds don't stop playing because i am Standing on the Part that opens the shop.
The objective here is:
I stand on the part>The shop open>One of the three sounds plays. The debounce should end when the store closes but I don't know how to do it
Here the script:
local open = game.Workspace.openPart
local close = game.Workspace.closePart
local frame = script.Parent
local closeButton = frame.closeButton
local buy_1 = frame.buy1
local buy_2 = frame.buy2
local sound1 = script.Parent.Sound1
local sound2 = script.Parent.Sound2
local sound3 = script.Parent.Sound3
local sounds = {
sound1,
sound2,
sound3
}
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild('BuyTool')
local LPlayer = game.Players.LocalPlayer
frame.Visible = false
local function shopMenu(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
local chosenSound = sounds[math.random(1, #sounds)]
local sound = chosenSound -- define your sound
if player == LPlayer then
player.PlayerGui.ScreenGui.Shop.Visible = true
sound:Play()
player.Character.Humanoid.WalkSpeed = 0
end
end
local function closeMenu() --Updated to use LPlayer
LPlayer.PlayerGui.ScreenGui.Shop.Visible = false
script.Parent.Goodbye:Play()
LPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(close.Position.X,close.Position.Y + 3,close.Position.Z)
LPlayer.Character.Humanoid.WalkSpeed = 16
end

3 comments
You could have a debounce that you only deactivate once you've closen the menu again
Make sure that 'looped' is set to false on the sound.
I mean the other sound keep playing because im standing on the part, not because the sounds were looped