Hello everyone, I have an intro for a game. I want to run it only when the player has loaded because if not, some players will not see it and others will have to wait too much.
Is there any way of doing this?
Thanks for reading!
Hello everyone, I have an intro for a game. I want to run it only when the player has loaded because if not, some players will not see it and others will have to wait too much.
Is there any way of doing this?
Thanks for reading!
You can use the game:IsLoaded
proerty to check if the game has loaded yet and if it returns false you can just use game.Loaded:Wait()
to know once it is loaded.
if not game:IsLoaded() then
game.Loaded:Wait()
end
What @0x6e7367 posted is the correct method. I didn’t understand what you were asking.
Make the script local so it will happen individually for each player. Do a wait (5) or (10) so that it only happens after the player loads.
He wants to wait for the player to load, OP are you doing this in a localscript or a serverscript
If a localscript then you can just put the raw code there, because it will run when the player has loaded
In a localscript if you want to wait for thier character to load then do
game.Players.LocalPlayer.CharacterAdded:Wait()
game.Players.LocalPlayer.CharacterAdded:Connect(function(Character)
-- Do something
end)
If a Server script and you want to wait for the player to load then do
game.Players.PlayerAdded:Wait()
game.Players.PlayerAdded:Connect(function()
-- Do something
end)
If a Server script and you want to wait for the player’s character to load then do
game.Players.PlayerAdded:Wait(function(Player)
Player.CharacterAdded:Wait()
end)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
-- do something
end)
end)
API:
RBXScriptSignal PlayerAdded(Instance Player);
RBXScriptSignal CharacterAdded(Instance Character);
Do this to gain access to the character, and also wait for the character:
local character = game.Players.YourPlayer.Character or game.Players.YourPlayer.CharacterAdded:Wait()
This is the cleanest way to make sure that the character has loaded without any other asynchronous waits.