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

Extreme scripting: Music Player Gui How do i make it Play?[Closed]

I have been working on this for a day or so it generates a sound changes the sound id, pitch and volume to whatever you put it works I just can't get it to play, it's supposed to play when you click the play button you can see the whole thing here: http://www.roblox.com/Halp-Me-item?id=172637290

Here is all the code that is probably causing something

print("SystemA Started")
Id = script.Parent.EveryThing.System.Id.NumberValue
Pitch = script.Parent.EveryThing.System.Pitch.NumberValue
Volume = script.Parent.EveryThing.System.Volume.NumberValue
do
	LocalSound = Instance.new("Sound")
	LocalSound.Parent = script.Parent
	LocalSound.Looped = false
	LocalSound.SoundId = "http://www.roblox.com/asset/?id="..Id.Value..""
	LocalSound.Pitch = Pitch.Value
	LocalSound.Volume = Volume.Value
end --works till here
while true do
	wait()
	if script.Play.Value == true then
		script.Play.Value = false
		LocalSound:Play()-- won't play it		
	end
	LocalSound.SoundId = "http://www.roblox.com/asset/?id="..Id.Value..""-- this also works till    -- end
	LocalSound.Pitch = Pitch.Value
	LocalSound.Volume = Volume.Value
end

please Help take a look at the model it should help you help me

1 answer

✓ Accepted answer

I took the model, the play button needs scripting so that when you click it, it changes the play value in the SystemA script to true. I have provided the fixed code here:

print("SystemA Started")
Id = script.Parent.EveryThing.System.Id.NumberValue
Pitch = script.Parent.EveryThing.System.Pitch.NumberValue
Volume = script.Parent.EveryThing.System.Volume.NumberValue
local Sound = Instance.new("Sound") --You had a random do above this line, so that has been removed, along with the extra end.
Sound.Parent = script.Parent
Sound.Looped = false
Sound.SoundId = "http://www.roblox.com/asset/?id="..Id.Value..""
Sound.Pitch = Pitch.Value
Sound.Volume = Volume.Value

while wait() do --Changed to "while wait() do" as it reduces the extra line.
	Sound.SoundId = "http://www.roblox.com/asset/?id="..Id.Value..""
	Sound.Pitch = Pitch.Value
	Sound.Volume = Volume.Value
	Sound:Stop() --Stops first so that you don't get the same sound playing multiple times.
	if script.Play.Value == true then
		script.Play.Value = false
		wait(1) --A delay to let the SoundId, Pitch and Volume change.
		Sound:Play()		
	end
	repeat wait() until script.Play.Value == true --Waits until the play value is true again so that it doesn't stop and replay the song in a loop, causing it to not play at all.
end

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