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

What the freak is making the wood step looperoni??

Asked by
4D_X 118
5 years ago

It loops the wood sound WAYYY too much when it's not even on wood. Please help me fix this script as I'm counting on it for a shooter I'm making

wait(1)
for i,v in pairs(game.Players.LocalPlayer.Character.Head:GetChildren()) do
    if v:IsA("Sound") then v:Destroy() end
end
function StopAllSounds(c)
    for i,v in pairs(script:GetChildren()) do
        if v:IsA("Sound") then
            if v.Name ~= c then v:Pause() end
end
    end
end
playwood = false
playstone = false
playmetal = false
repeat
    if game.Players.LocalPlayer.Character.Humanoid.moveDirection ~= Vector3.new(0,0,0) and game.Players.LocalPlayer.Character.Humanoid.Jump ~= true then
        print(game.Players.LocalPlayer.Character.Humanoid.FloorMaterial)
        if game.Players.LocalPlayer.Character.Humanoid.FloorMaterial == Enum.Material.Wood or Enum.Material.WoodPlanks then
            StopAllSounds() playwood = false playstone = false playmetal = false
            if playwood == false then
                playwood = true
                print('Playing Wood')
                script.Wood:Play()
            end
        elseif game.Players.LocalPlayer.Character.Humanoid.FloorMaterial == Enum.Material.Concrete or Enum.Material.Asphalt or Enum.Material.Brick or Enum.Material.Cobblestone or Enum.Material.Asphalt or Enum.Material.Basalt then
            StopAllSounds() playwood = false playstone = false playmetal = false
            if playstone == false then
                playstone = true
                print('Playing Stone')
                script.Stone:Play()
            end
            elseif game.Players.LocalPlayer.Character.Humanoid.FloorMaterial == Enum.Material.Metal or Enum.Material.CorrodedMetal or Enum.Material.DiamondPlate then
            StopAllSounds() playwood = false playstone = false playmetal = false
            if playmetal == false then
                playmetal = true
                print('Playing Metal')
                script.Metal:Play()
            end
                else StopAllSounds() playwood = false playstone = false playmetal = false
            end
                else StopAllSounds() playwood = false playstone = false playmetal = false
            end
    wait()
until not workspace -- don't ask cause idk lol
0
. . . HaveASip 494 — 5y

1 answer

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

You are re-starting the sound every time the player moves. All you need to do is put a longer time into the wait() at the end of the code.

Regarding your comment at the end, it is better to do:

while true do

end

than

repeat

until not workspace
Ad

Answer this question