Earlier today a friend of mine requested a few scripts, and I went ahead and made them because I've only started cracking down on learning Lua earlier this year and really needed the practice.
One of these scripts was pretty simple - make a sound play when a part is touched. After a while I had whipped this up.
local playing = false function MakeSound() if playing == false then local sound = Instance.new("Sound") sound.Parent = script.Parent sound.SoundId = "http://www.roblox.com/asset/?id= " --Sound ID goes here sound:Play() playing = true wait(1) playing = false sound:Destroy() --can't leave all these played sounds laying around elseif playing == true then return end end script.Parent.Touched:connect(MakeSound)
For some reason it worked in solo, but not online. I realized I over-complicated it so I changed it to simply play a pre-existing sound when touched, and now it works online.
But I'm curious just in case this problem ever arises again in my scripts... what IS the problem? Why'd it work in solo but not online?
Try using it as a LocalScript.