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

Intro only play once per game not global?

Asked by 9 years ago

Okay I made a intro (Music included) and I want to make it so once a player joins it starts the intro, intro is in startergui but every time a player dies it starts over and over.. you get the point how would i make it so it only plays once even for new players but if you die it doesn't play? if you need more information or don't get it post in comments please!

2 answers

Log in to vote
1
Answered by
ImageLabel 1541 Moderation Voter
9 years ago

Your problem is that your "intro" is located in StarterGui. All instances in this service are replicated to the PlayerGui container inside of every player, and are reset every time the player re-spawns mostly for updating purposes.

You would want to store your GUI in the (ReplicatedStorage) service or ServerStorage service, so that you may clone them into the player's PlayerGui only when they join the server. After they re-spawn, the GUI would be cleared, and no longer replicate.


local file = game:GetService('ReplicatedStorage'):WaitForChild('GUI')

game:GetService('Players').PlayerAdded:connect(function (player)
    repeat until player.Changed:wait() == 'Character'
    print('character')
    --clone Gui into `player.PlayerGui` 

    newGui = file:clone()
    newGui.Parent = player.PlayerGui
end)

-- which is pretty much similar to Goulstem CharacterAdded:wait()
0
I don't understand i get the point of which it moves to playergui but I've placed it into replicatedstorage how would I clone it to playergui? DiamondCookie2 0 — 9y
0
I edited it with an example of cloning ImageLabel 1541 — 9y
Ad
Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Instead of using the CharacterAdded event, just wait until the character loads inside of a PlayerAdded event.

Example;

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:wait()
    --code
end)

Answer this question