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

What the freak is making the wood step looperoni??

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

1 comment

0

. . .

1 answer

✓ Accepted answer

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

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