I have been trying to figure out how to create a script for a character to load first before the other scripts take place. I have been trying to figure this out because I need a sound to play in an area when the character has touched the brick that has the sound in it, however, it only plays for two seconds and then stops because the character is not fully loaded in. Anyone know how to make a script to wait for the character to load? Here are my music scripts.
script.Parent.Touched:connect(function(part) local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then script.Parent.MufiaPlaza:Play() end end)
Here is the second script for when the character leaves the "Part."
script.Parent.TouchEnded:connect(function(part) local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then script.Parent.MufiaPlaza:Stop() end end)
Ok, so I just made a long answer and figured out that its not the fact that the character isn't loaded thats wrong with your script. Your music is trying to play constantly which means it is going to keep restarting because a player will touch the part infinite times in a second. What you need to do is set a variable to true and make sure that it isn't false before you play the music. Now I hope I helped xD