Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

A script of mine works in solo, but not online?

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?

5 comments

0

Did you forget to append a soundId on line 7?

0

Even with a SoundId set it worked in solo, but not online when we tested it. Also I feel like I didn't make it clear but I have a fix, it's just I don't know why this over-complicated iteration of it didn't work online.

0

Is it activating or not (ex: sound is not being created)?

0

I'm not sure, is there any kind of in-game explorer so I can see what it's doing online?

0

Well thanks for trying to help me understand what's wrong, but considering someone here described a very similar problem I'm just going to chalk it up as being a quirk with sound.

1 answer

Try using it as a LocalScript.

  • Kratos232

1 comment

0

That worked, but I had to pretty heavily modify everything so it didn't answer my problem: I don't understand why that script in the OP (with a SoundId set of course) works when testing in solo with studio, but not online.

This discussion is preserved as it was. New answers, comments, and votes are closed.