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

Why doesn't it work?!?

Asked by
Bulvyte 388 Moderation Voter
8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

So if i put my intro music into the starter gui it always plays when you die/reset i've made this clone script only plays the music when you enter the game and never again.

local Sound = script.Sound:Clone()
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:wait()
    Sound:Clone().Parent = player.PlayerGui
    wait(.1)
    Sound:Play().Parent = player.PlayerGui
end)

The thing i want is: Let it clone to playergui which works, but doesn't play the sound. So the prob is i want to make it play when it clones the sound. Help pls...

2 answers

Log in to vote
0
Answered by 8 years ago

Well, I believe sound only plays in two places: The Player & The Workspace. Sounds don't work in other places like the PlayerGui.

Workspace: Plays Sound For Everyone

player.Sound:Play()

The Player: Plays sound for ONE person only.

workspace.Sound:Play()

Maybe you want to do this, instead of putting the sound in the GUI, put it in the player.

local Sound = script.Sound:Clone()
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:wait()
    Sound:Clone().Parent = player
    wait(.1)
    Sound:Play().Parent = playeri
end)
0
Thank youuuu :3 Bulvyte 388 — 8y
0
No Problem! Make sure to leave an upvote :3 laughablehaha 494 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

Your problem is that you have incorrect syntax.

Sound:Play().Parent is not correct syntax.

I'm assuming what you want to happen is that the sound is cloned into the playergui and then the sound plays after 0.1 seconds. I would suggest setting the clone of the sound to a local variable, and then setting that variable's parent to the playergui, and then after 0.1 seconds make the variable play, like so:

local soundClone = Sound:Clone()
soundClone.Parent = player.PlayerGui
wait(0.1)
soundClone:Play()

Hope this helped!

0
http://prntscr.com/879o1a This is how it looks, it doesn't even clone the sound to PlayerGui doesn't work :/ Bulvyte 388 — 8y

Answer this question