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

Intro only play once per game not global?

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

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)

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()

2 comments

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?

0

I edited it with an example of cloning

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