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

I want make random sounds for sword like when you use slash you can get sound1 or sound2?

title +

local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxassetid://211059855"
SlashSound.Parent = sword
SlashSound.Volume = .7

local LungeSound = Instance.new("Sound")
LungeSound.SoundId = "rbxassetid://357622136"
LungeSound.Parent = sword
LungeSound.Volume = .6

local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "rbxassetid://211059653"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 1

1 comment

2 answers

If you want random sounds to play, this should do it.

local soundPlayed

local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxassetid://211059855"
SlashSound.Parent = sword
SlashSound.Volume = .7
 
local LungeSound = Instance.new("Sound")
LungeSound.SoundId = "rbxassetid://357622136"
LungeSound.Parent = sword
LungeSound.Volume = .6
 
local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "rbxassetid://211059653"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 1

function playSound()
	soundPlayed = math.random(0,2)
	if soundPlayed = 0 then
		SlashSound:Play()
	elseif soundPlayed = 1 then
		LungSound:Play()
	elseif soundPlayed = 2 then
		UnsheathSound:Play()
	end
end

Call playSound() for a random sound from your list. I have not tested it, so please check for errors. I hope this helps.

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