I wrote this script while I was in studio and it worked when I tested it (In studio) but when I tested it out in the actual game it didn't work. Can someone please help me fix this or give me advice on how I can fix it.
Script:
local SP = script.Parent function onTouch(hit) hit.Parent.Humanoid.CoinCollect:Play() end script.Parent.Touched:connect(onTouch)
The Best Answer and I promise u this will help! Click F9 while running the game to see your errors or use output window to see any errors relating to the game. That is how I solve my studio but not in game errors. If this was the best answer, click accept answer. Good Luck with your game!
If this script is inside the coin, you don't need the audio to play from the Humanoid.
function onTouch(hit) script.Parent.Sound:Play() -- Whatever the audio file is named, "Sound" "Coin" etc. end script.Parent.Touched:connect(onTouch)