for my main game script when a player joins it does some stuff and then inside that playerAdded function i have Player.CharacterAdded but sometimes when i join the game the characteradded event doesnt fire. is this because of some lag or something else.
game.Players.PlayerAdded:Connect(function(Player)
script.Load:Clone().Parent = Player.PlayerGui --Insert Loading Screen to load assets
--Variables
local PlayerFolder = Instance.new("Folder")
local PlayerState = Instance.new("StringValue")
local PlayerLevel = Instance.new("IntValue")
local PlayerCash = Instance.new("IntValue")
local PlayerTime = Instance.new("IntValue")
local PlayerColour = Instance.new("StringValue")
local PlayerEquippedTrail = Instance.new("StringValue")
local PlayerEquippedOutfit = Instance.new("StringValue")
--Locations
PlayerFolder.Parent = PlayerInfo
PlayerState.Parent = PlayerFolder
PlayerLevel.Parent = PlayerFolder
PlayerCash.Parent = PlayerFolder
PlayerColour.Parent = PlayerFolder
PlayerTime.Parent = PlayerFolder
PlayerEquippedTrail.Parent = PlayerFolder
PlayerEquippedOutfit.Parent = PlayerFolder
--Names
PlayerFolder.Name = Player.Name
PlayerState.Name = "PlayerState"
PlayerLevel.Name = "PlayerLevel"
PlayerCash.Name = "PlayerCash"
PlayerColour.Name = "PlayerColour"
PlayerTime.Name = "PlayerTime"
PlayerEquippedTrail.Name= "PlayerEquippedTrail"
PlayerEquippedOutfit.Name = "PlayerEquippedOutfit"
--Values
PlayerState.Value = "LoadingScreen"
PlayerColour.Value = "Yellow"
PlayerTime.Value = 0
PlayerLevel.Value = 1
PlayerCash.Value = Player:WaitForChild("PlayerInfomation"):WaitForChild("Cash").Value
local DataStore = game:GetService("DataStoreService")
local Equipped = DataStore:GetDataStore("EquippedDataStorage")
local Equipment = Equipped:GetAsync(Player.UserId) or {Trail = "DefultTrail", Outfit = "DefultOutfit"}
local MaxLevel = 8
PlayerEquippedTrail.Value= Equipment["Trail"]
PlayerEquippedOutfit.Value = Equipment["Outfit"]
local Players = game.Workspace.PlayerInfomation:GetChildren()
for i = 1,#Players do
game.ReplicatedStorage.LeaderboardEvents.NewPlayersInfo:FireClient(Player, Players[i].Name, Players[i].PlayerLevel.Value, Players[i].PlayerTime.Value)
end
game.ReplicatedStorage.LeaderboardEvents.PlayerState:FireAllClients(Player, false)
--Local Functions
---ChangeColour
--Event Functions
---State Changed (From Client)
game.ReplicatedStorage.PlayerEventsAndFunctions.StateChange.OnServerEvent:Connect(function(TargetPlayer,State)
if TargetPlayer == Player then
PlayerState.Value = State
end
end)
---Player Wants To Chnage Colour
game.ReplicatedStorage.PlayerEventsAndFunctions.SwitchUp.OnServerEvent:Connect(function(TargetPlayer)
if TargetPlayer == Player then
local Items = Player.Character:GetChildren()
ColourChange(PlayerColour.Value)
end
end)
--Character Spawns
Player.CharacterAdded:Connect(function(Character)
print("Player character spawned")
Heres the script incase it helps. sorry if theres any weird prints in it i forget what i add