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

How would i add sound to this script? So when i press a button the sound activate with the script.

Asked by
exarlus 72
6 years ago

Basically i wanna add sound to this script so whenever you click x the sound plays of course along with the script activating.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
enabled = false

local animation = Instance.new("Animation",script)
animation.AnimationId = "http://www.roblox.com/asset/?id=903141670"
local animation2 = Instance.new("Animation",script)
animation2.AnimationId = "http://www.roblox.com/asset/?id=903173770"
mouse.KeyDown:connect(function(key)
    if key == "x" and enabled == false then --turns on
    enabled = true
    local SSJ = player.Character.Humanoid:LoadAnimation(animation)
    SSJ:Play()
    wait(3)--However long your animation is basically
    local SSJParticle = game.ReplicatedStorage.Particles.SSJ:Clone()
    SSJParticle.Parent = player.Character.HumanoidRootPart
    local SSJHair = game.ReplicatedStorage.Hairs.SSJ:Clone()
    SSJHair.Parent = player.Character
    SSJHair.CFrame = player.Character.HumanoidRootPart.CFrame
    local Weld = Instance.new("Weld")
    Weld.Name = "SSJ"
    Weld.Parent = player.Character.Head
    Weld.Part0 = player.Character.Head
    Weld.Part1 = SSJHair
    Weld.C0  = CFrame.new(0, .9, 0.11) * CFrame.Angles(0,math.pi,0)
    player.Character.Humanoid.MaxHealth = 5000
    player.Character.Humanoid.Health = 5000
    player.Character.Humanoid.WalkSpeed = 25
    else if key == "x" and enabled then-- turns off.
    local SSJ2 = player.Character.Humanoid:LoadAnimation(animation2)
    SSJ2:Play()
    player.Character.Head:FindFirstChild("SSJ"):Remove()
    player.Character:FindFirstChild("SSJ"):Remove()
    player.Character.HumanoidRootPart:FindFirstChild("SSJ"):Remove()
    player.Character.Humanoid.WalkSpeed = 16
    player.Character.Humanoid.MaxHealth = 100
    player.Character.Humanoid.Health = 100
    wait(1)
    enabled = false
    end
    end
end)

1 answer

Log in to vote
0
Answered by 6 years ago
Sound:Play() -- Plays the sound
Sound:Pause() -- Pauses the sound
Sound:Resume() -- Resumes the sound only if paused.
Sound:Stop() -- Stops the sound, cannot be resumed.

-- Replace sound with the location of your sound instance.
Ad

Answer this question