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

Need help with a music Block Please! (?)

Asked by 8 years ago

I tried to make it so that you can only hear music if you are in a certain box

function Music()

script.Parent:Play()

wait(script.Parent.Music.TimeLength)

end

function MusicStop()

script.Parent:Stop()

end

script.Parent.Parent.Touched:connect(Music)
script.Parent.Parent.TouchEnded:connect(MusicStop)

Troubles: There are no error reports in the ouput box, but the music doesn't play when I'm in the box

0
Use prints to see where the script stops. TheDeadlyPanther 2460 — 8y
0
TouchEnded can be very unreliable. And you're handling the audio on the server so if someone else were to stop touching it then the music would stop even if you're still in it. Handle the audio on the client and I suggest using magnitude to detect whether or not the player is within distance. Goulstem 8144 — 8y
0
'TouchEnded' triggers anytime a player moves, because 1 of their feet lift up for the slightest second, ended the touch. I would recommend putting parts all around this part you're stepping on, (union if you want to), and put the second half of your script into that union/parts. User#9949 0 — 8y
0
I'm not sure what you're trying to do, why do you have wait(script.Parent.Music.TimeLength) with nothing after it? General_Scripter 425 — 8y
View all comments (2 more)
0
they should deprecate touchended. With alot of this, as stated earlier, it can be very unreliable koolkid8099 705 — 8y
0
How would I use magnitude to find whether or not a player is in the box? connor12260311 383 — 8y

Answer this question