Why is this not working

Yes you made it so I cant Destroy it on InputEnded

1 Like

The code that I gave you prevents you from spam playing it using Sound.IsPlaying. You said you wanted to create a new sound every time though. You could use a debounce to accomplish this, but I do not understand what a debounce would accomplish that the code I gave you doesn’t. Do you want to allow some overlap of the sounds? Or none at all? The code I gave you provides none at all because it uses the Sound.IsPlaying attribute, but that is what you said you wanted to use.

You obviously can’t send http requests in a local script. Only normal scripts

And another way to spot the error is by making a pcall function

Because Hackers can just delete the sound but if I keep creating new ones then they cant

AGAIN no errors
No HttpRequests

Try plr:GetMouse().Button1Down instead of inputbegan, maybe that will work.

That is not the problem here the inputs are working its the sound

Again pcall only works if you know its going to error not if its not erroring

This will create a new sound if the sound has been deleted. At the same time it will only play if the sound isn’t playing.

local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")

local Sound = nil

local function createSound()
	local Sound = Instance.new("Sound")
	Sound.Name = HttpService:GenerateGUID()
	Sound.SoundId = "http://roblox.com/asset/?id=873129141"
	Sound.Parent = Players.LocalPlayer.Character
	return Sound
end
Sound = createSound()

UserInputService.InputBegan:Connect(function(InputBegan)
	if InputBegan.UserInputType == Enum.UserInputType.MouseButton1 then
		if not Sound then
			Sound = createSound()
		end
		
		if not Sound.IsPlaying then
			Sound:Play()
		end
	end
end)

Have you tried checking the output yet?

HOW WOULD i create a debounce dont give doc just example

I’m just trying to help, I have read it, but I did not see if you read the out put.

image

Okay, have you tried looking in the developer console? There might be an error there if you click the “server” button!

A debounce would look something like this:

local debounce = false

if not debounce then
    debounce = true
    -- code
    debounce = false
end

dont see how that can be added to my code

This part of the code is the debounce:

You can try putting it in random spots and testing it to see if it does what you want @xDeltaXen

You mean time wasting I dont do trial and error

Already tried that and it did not work