Title, there is one Module Script
, that I use to play sounds when you hover or press a Text Button
; however, it uses the wrong sound id
I will show a few scripts for context:
local SoundService = game:GetService("SoundService")
local AudioPlayer = {}
AudioPlayer.setupAudio = function(assetArray)
for name, audioID in pairs(assetArray) do
local audioInstance = Instance.new("Sound")
audioInstance.SoundId = "rbxassetid://"..6052548458
audioInstance.SoundId = "rbxassetid://"..12563989892
audioInstance.SoundId = "rbxassetid://"..6895079853
audioInstance.SoundId = "rbxassetid://"..552900451
audioInstance.Name = name
audioInstance.Parent = SoundService
end
end
AudioPlayer.playAudio = function(assetName)
local audio = SoundService:FindFirstChild(assetName)
if audio then
if not audio.IsLoaded then
audio.Loaded:Wait()
end
audio:Play()
end
end
return AudioPlayer
here’s one of the scripts i use for playing the sounds in the button:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AudioPlayer = require(ReplicatedStorage:WaitForChild("AudioPlayer"))
AudioPlayer.setupAudio({
["button_click"] = 552900451
})
local textBUtton = script.Parent
textBUtton.Activated:Connect(function()
AudioPlayer.playAudio("button_click")
end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AudioPlayer = require(ReplicatedStorage:WaitForChild("AudioPlayer"))
AudioPlayer.setupAudio({
["uiHoverClick"] = 6895079853
})
local button = script.Parent
button.MouseEnter:Connect(function()
AudioPlayer.playAudio("uiHoverClick")
end)
button.MouseLeave:Connect(function()
AudioPlayer.playAudio("uiHoverClick")
end)
Sound Ids for both just incase: uiHoverClick = 6895079853
button_click = 552900451
Looks fine right? Unfortunely, this happens:
Look; the uiHoverClick has the same soundId as Button_Click
.
Please help me fix this issue, as I have no idea why this is occuring.