Ad
Log in to vote
0

How can I enable and disable walking sounds?

Asked by 4 months ago
Edited 4 months ago

I am trying to enable walking sound when I am not flying. I have a flying script and whenever I fly I want the game to disable walking sound because in mid-air while flying I hear walking sound. How can I enable walking sound while I am not flying and disable while I am flying?

local wDown = false
local sDown = false
local isFlying = false
local speed = 10
local MAX_SPEED = 45
local MIN_SPEED = 0
spawn(function()
    while player.Character.Humanoid.Health > 0 do
        if isFlying then
            local r = 1+(speed/45)
            player.Character:SetPrimaryPartCFrame(CFrame.new(player.Character.PrimaryPart.Position,mouse.Hit.p)*CFrame.Angles(math.pi/r,math.pi,math.pi))
            player.Character.Torso.FlyingVelocity.Velocity = (mouse.Hit.p - player.Character.Torso.Position).unit * speed
            if wDown then
                speed = speed + 5
                if speed > MAX_SPEED then
                    speed = MAX_SPEED
                end
            elseif sDown then
                speed = speed - 5
                if speed < MIN_SPEED then
                    speed = MIN_SPEED
                end
            end
        end

        game:GetService("RunService").RenderStepped:wait()
    end
end)

1 answer

Log in to vote
0
Answered by
kingdom5 4031 Trusted Snack Break Moderation Voter
4 months ago

I would not diable it as it may cause errors in other script instead I would set the volume to 0. All of the players sounds are current in the Head so you can simple set the volume of running to 0.

Example:-

script.Parent:WaitForChild('Head'):WaitForChild('Running').Volume = 0

-- def value
script.Parent:WaitForChild('Head'):WaitForChild('Running').Volume = 0.65

Hope this helps.

Ad

Answer this question