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

Why does it sometimes make the sound and sometimes doesn't?

Asked by 4 years ago

debounce = false

local Coin = script.Parent

local function Part(TouchPart)

if not debounce then

debounce = true

local partParent = TouchPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")


if ( humanoid ) then
        workspace.Coins.Fake.Sound:Play()
end

debounce = false
end

end

Coin.Touched:Connect(Part)

Sometimes it makes the sound when you touch a coin sometimes it doesn't

I have this in every coin

The sound is in a different coin named "Fake" referenced in the script

If anyone knows the problem please tell me

0
I would suggest placing print functions inside the function to try and look at what exactly is happening and why the sound isn't playing. sheepposu 561 — 4y
0
For example you could print the value of debounce or the value of humanoid and see what it's saying and where it's going wrong. sheepposu 561 — 4y
0
@sheepposu how JLKMaster 0 — 4y

Answer this question