Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
esik 0
7 years ago

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

2 answers

Log in to vote
0
Answered by 7 years ago

Do

Sound:Play()
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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.

Answer this question