Need help on making sounds when donation occurs

hello. i want a random sound to play when i get a donation from a donation board that isn’t mine, but right now i only have this script…

return {
    [1] = {
        Robux = NumberRange.new(1, 999999999),
        
        GuiAnnouncement = true,
        ChatAnnouncement = true,
        WebhookAnnouncement = true,
        
        ChatColor = Color3.fromRGB(0, 255, 0),
        GuiColor = Color3.fromRGB(0, 255, 0),
        WebhookColor = Color3.fromRGB(0, 255, 0),
        
        ChatFont = Enum.Font.GothamBlack,
        GuiFont = Enum.Font.GothamBlack,
        
        ChatLayout = "[PLR] has donated [AMOUNT] Robux!",
        GuiLayout = "[PLR] has donated [AMOUNT] Robux!",
        WebhookLayout = "[PLR] has donated [AMOUNT] Robux!",
        
        GuiDuration = 5,
        ChatSize = 18,
        
        SFX = {
			Id = 5992677089,79592622325234,
			Length = 4
        }
    }
}

this is only a module script, and the full script is in require(asset id). is there any help? i don’t really know how to script properly…

1 Like

Hello!

This is more of an example

local module = require(game.ReplicatedStorage:WaitForChild("soundProperties"))

local sound = Instance.new("Sound")
sound.Parent = game.SoundService

script.Parent.MouseButton1Click:Connect(function()
	local randomnumber = math.random(1, 2)
	if randomnumber == 1 then
		
		sound.SoundId = "rbxassetid://"..module.ID
		sound:Play()
	end
	if randomnumber == 2 then
		sound.SoundId = "rbxassetid://"..module.ID2
		task.wait(0.5)
		sound:Play()
	end
end)

What happens here, is that when a button is pressed, it plays a sound, but it’s id is random and depends on the math.random() number. In your module, i’d recommend having the SFX like this:

        SFX = {
			Id = 5992677089,
            Id2 = 79592622325234,
			Length = 4
        }

This is my module:

local SFX = {
	ID = 5992677089,
    ID2 = 79592622325234,
	
}

return SFX

This may be not the best example, but I hope this somehow helps! Bye!

thanks man! i needed that help. (works btw)

1 Like