Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How come this code works in Play Solo mode, but not Online mode?

Asked by
Minifig77 190
10 years ago

The problem: I'm making a speaker system for a game, and a common problem is that the sound is not loaded right away whenever you try to play it. This results in different speakers starting to play at different times, or, to paraphrase, the sounds are out of sync. My solution is to add a 'sync' button that resets the sound id in the speakers, making them re-play the sound, but at the same time. Once I thought I had finished, I tested it in Play Solo and it worked just fine. A day or so later, I tried to use it in the actual game and found out that it simply broke the sound system so you couldn't change the sound id. For some strange reason, the button only works in Play Solo mode.

Background information: I engineered the sound system so you could add as many speakers as you wanted, and they would all be connected. To do this, I made the speakers connect to a NumberValue in the DJ table. Whenever a user enters a SoundId, the NumberValue adjusts to the ID number. The speakers use the Changed event to check whenever the NumberValue is changed, and when it does, they then concatenate the ID into proper Asset syntax.

The code:

--This part works fine in Online mode.
function TextChange()
    if script.Parent.Parent.PSID.Value ~= "" then
        Display.Text = ""
        script.Parent.Parent.Parent.Parent.SID.Value = tonumber(script.Parent.Parent.PSID.Value)
        script.Parent.Parent.PSID.Value = ""
--Below is the first line of the broken code.
    else
        TemporaryValue = script.Parent.Parent.Parent.Parent.SID.Value
        script.Parent.Parent.Parent.Parent.SID.Value = 0 --Too lazy to create a local value for it...
        script.Parent.Parent.Parent.Parent.SID.Value = TemporaryValue --Still too lazy...
--End of the broken code above.
    end
end
script.Parent.MouseButton1Click:connect(TextChange)

NOTE: The hierarchy is correct. I checked.

0
The sound not being loaded right away is common, you would need to preload the sound one time before playing it, so the actual sound plays the first time you active it, ROBLOX is fixing this if I'm not wrong, actually they made a recent blog of the new sound system that would avoid this. Slazerick 55 — 10y
0
The problem is that the button doesn't work in Online mode, only in Play Solo mode. Minifig77 190 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago

Sometimes if scripts are too long in Studio for GUIs they only work in Play Solo. It happened to me. All I did was put certain parts of the script in different scripts.

Ad

Answer this question