of     1   

j818
#138933631Wednesday, July 02, 2014 2:14 AM GMT

I have a coins around a map, and when you touch it it gives you 1 coin. And plays a coin noise. It works in Test>Play solo, but not In normal game. Why doesn't it work? Here is the script: function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if (h~=nil) then local thisplr = game.Players:findFirstChild(h.Parent.Name) if (thisplr~=nil) then local stats = thisplr:findFirstChild("leaderstats") if (stats~=nil) then script.Parent.Bling:Play() local score = stats:findFirstChild("Coins") if (score~=nil) then score.Value = score.Value + 1 script.Parent.Bling:Play() script.Parent:Remove() end end end script.Disabled = false end end script.Parent.Touched:connect(onTouched)
xXBestPieXx
#138933747Wednesday, July 02, 2014 2:15 AM GMT

Is it in a localscript?
j818
#138933947Wednesday, July 02, 2014 2:17 AM GMT

No it is not. Should it be?
xXBestPieXx
#138934029Wednesday, July 02, 2014 2:17 AM GMT

For the noise, yes. Try the whole script in a localscript.
j818
#138934792Wednesday, July 02, 2014 2:24 AM GMT

I tried the whole script, and i couldn't even pick up the coin then... Then i tried the sound, and it didn't play :(
j818
#138939557Wednesday, July 02, 2014 3:10 AM GMT

Bump
Knexer
#138939840Wednesday, July 02, 2014 3:12 AM GMT

I happen to agree with pie. If this script is dependent on another, try combining all of the functions that need to be local and try again. If it works in solo, but not in-game, the script-type is usually the problem, as all of the scripts in solo are ran locally.
j818
#138945410Wednesday, July 02, 2014 4:12 AM GMT

It plays the sound... But it gives 5 or 10 coins on each hit. I only want it to give 1. function onTouched(part) local h = part.Parent:findFirstChild("Humanoid") if (h~=nil) then local thisplr = game.Players:findFirstChild(h.Parent.Name) if (thisplr~=nil) then local stats = thisplr:findFirstChild("leaderstats") if (stats~=nil) then local score = stats:findFirstChild("Coins") if (score~=nil) then score.Value = score.Value + 1 script.Parent.Bling:Play() wait(0.00001) end end end script.Parent:Remove() script.Disabled = false end end script.Parent.Touched:connect(onTouched) I switched the wait but the sound didn't play. It seems this is the only way it will make the sound.
Notunknown99
#138947065Wednesday, July 02, 2014 4:33 AM GMT

script.Parent.Bling:Play() script.Parent:Remove() I don't think it likes being removed before it can play....
Notunknown99
#138947113Wednesday, July 02, 2014 4:34 AM GMT

Add a debounce then.
Knexer
#138951048Wednesday, July 02, 2014 5:10 AM GMT

Yeah, if it's giving 5 or ten, debounce is the problem.

    of     1