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

How can i put a sound while playing an animation?

Asked by 5 years ago

It's a self killing script. It goes like this:

local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()

local Key = 'R'

local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://3690421923'

UIS.InputBegan:Connect(function(Input, IsTyping)
    if IsTyping then return end
    local KeyPressed = Input.KeyCode
    if KeyPressed == Enum.KeyCode[Key] then
        Debounce = false
        local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
        LoadAnimation:Play()
        wait(1.24)
        Player = game.Players.LocalPlayer.Character.Head
        Player:Destroy()
        Debounce = true
    end
end)

I need to make a sound after the wait(1.24) command

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You could put a sound in playergui and just make it play

local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()

local Key = 'R'

local Animation = Instance.new("Animation")
Animation.AnimationId = 'rbxassetid://3690421923'

UIS.InputBegan:Connect(function(Input, IsTyping)
    if IsTyping then return end
    local KeyPressed = Input.KeyCode
    if KeyPressed == Enum.KeyCode[Key] then
        Debounce = false
        local LoadAnimation = Char.Humanoid:LoadAnimation(Animation)
        LoadAnimation:Play()
        wait(1.24)
        plr.PlayerGui.Sound:Play()
        Player = game.Players.LocalPlayer.Character.Head
        Player:Destroy()
        Debounce = true
    end
end)
0
oh okay. uCrafter21 0 — 5y
Ad

Answer this question