Sound Random Player Error

So, I’ve been working on this script that plays a random sound every time it’s clicked then it waits for a denounce. This script works for everything else ever since the update of Roblox Studio. When I tried to use the script again on another part, it works only like a limited amount of times until I get this one specific error that checks if the “IsPlaying” property of the sound is false; it checks if the HingeConstraint is less than 0. If it is false, it will play again. But for some reason, it works only once or twice then gives me this error:
image

How could it possibly work twice? But sooner defined ‘IsPlaying’ as nil. Then it won’t run ever again in the game.
Here’s the script:

local MusicTable = {"HammerHitSound", "HammerHitSound", "HammerHitSound","HammerHitSound", "SquishyPunch"," SquishyPunch", "BoneBreakingHitSoundFX"}
local Folder = workspace:FindFirstChild("WipeoutSounds")
local Constraint = script.Parent.Parent.Parent.Parent.HammerHinge.HingeConstraint
local db = false

script.Parent.Touched:Connect(function(plr)
	if db == false and plr.Parent:FindFirstChild("Humanoid") and Constraint.TargetAngle < 0 then
		db = true
		local Music = Folder:FindFirstChild(MusicTable[math.random(1, #MusicTable)])
		if Music.IsPlaying == false then
		Music:Play()
		wait(1.5)
			db = false
			end
	end
end)

I think I see the problem. On one of the values in your table, you wrote " SquishyPunch" (with a space at the beginning) rather than just “SquishyPunch.” Since parts in Roblox can’t start with a space, I’m pretty sure this is the issue.

1 Like

Ohhh, thanks I’ll try that once my computer gets fixed, thanks bro. I truly appreciate it.

1 Like