Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do i make a footstep sound randomizer?

First things first im making a showcase game and i want custom footstep sounds. So i have 2 audios i put up on roblox and i would like to use them. So how do i use math.random for audios?and i want to make it so when you walk the random sound plays.

1 answer

You could add the sounds to a folder in ReplicatedStorage, then do the following:

local audio = math.random(1, #pathToFolderInReplicatedStorage:GetChildren())
audio:Play()

EDIT: Misread, didn't realize you wanted to replace a sound, lol.

You'll want to put this in a LocalScript in StarterCharacterScripts (since you'll be changing default attributes of every character)

player = script.Parent
sounds = player.Head:waitForChild("Running")

local audio = math.random(1, #pathToFolderInReplicatedStorage:GetChildren())
local id = "rbxassetid://"..audio.SoundId

sounds.SoundId = id

4 comments

0

but where do i put the sound walking code

0

Updated the answer, let me know if you are curious about anything

0

its not working tho because when i try the game then it only does the original footstep sound

0

what do i do

This discussion is preserved as it was. New answers, comments, and votes are closed.