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

How can i put a sound while playing an animation?

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

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)

1 comment

0

oh okay.

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