How do i make a sound loop when toggled?

oh, I didn’t know that, thanks for letting me know

Try to change Sound.Playing to Sound.IsPlaying
And Sound:Stop() Instead Sound:Destroy()
You also can remove Sound.Lopped

-- Local Script

local UserInputService = game:GetService("UserInputService")

local Configurations = {
	Path_To_Sound = script.trr,
	Key_Code = "Z",
	Sound_Starts_When_Game_Starts = true
}

if Configurations.Sound_Starts_When_Game_Starts then
	Configurations.Path_To_Sound:Play()
end

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if not gameProcessedEvent and input.KeyCode == Enum.KeyCode[Configurations.Key_Code] then
		if Configurations.Path_To_Sound.IsPlaying then
			Configurations.Path_To_Sound:Pause()
		else
			Configurations.Path_To_Sound:Play()
		end
	end
end)

The looped effect was what OP actually wants.


What do you mean?

In their first post:
My goal here is to make a sound loop when toggled. And when you toggle it off, it stops. Any help? Thanks.

1 Like