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)

9 comments
What was the error?
And what is the script supposed to do?
It was supposed to play a sound when you collect a coin.
I think.
I have no idea how this could not work...
do you have it in the right area in the Workspace?
There's a Humanoid placed in StarterPlayer, inside the Humanoid there is an Audio. When the player touches the coin (part) it plays the audio inside the Humanoid.
The script in question is placed inside the coin.
I do things in an abstract way, sorry for the confusion guys.