Bug with player added

So with the player added in solo bug, I have a script that has characterloaded function in it to? So I tried using both and it did not work, any help?

game.Players.PlayerAdded:connect(function(player)
	for _, player in pairs(Players:GetPlayers()) do
	onPlayerAdded(player)
	player.CharacterAppearanceLoaded:Connect(function(character)

I’m assuming this is the entire code. The issue is, you have nothing to end the function. I also recommend using CharacterAdded instead of CharacterAppearanceLoaded, unless if it’s absolutely necessary.

game.Players.PlayerAdded:connect(function(player)
	onPlayerAdded(player)
	player.CharacterAdded:Connect(function(character)
         -- code
    end) -- Encloses "player.CharacterAdded"
end) -- Encloses "game.Players.PlayerAdded"

If this is not the issue, can you check the output for any errors?

there is no output errors from what I see, and no this did not work.

local CharacterAdded = (function (Character)
	--> Character things
end)

local PlayerAdded = (function (Player)
	Player.CharacterAdded:connect(CharacterAdded)
	--> other player stuff here

end)

--> Set up for new players
game.Players.PlayerAdded:connect(PlayerAdded)

--> Set up for players, and their respective characters, that are already instanced
for _, Player in next, game:GetService("Players"):GetPlayers() do
	if Player.Character then
		CharacterAdded(Player.Character)
	end
	PlayerAdded(Player)
end

This will work, it’s because your player/character is instancing prior to the script running.

2 Likes

Is it a local script or a regular script?

Isn’t the problem you have two variables both called player?

game.Players.PlayerAdded:connect(function(player) This line of code makes the player variable.

for _, player in pairs(Players:GetPlayers()) do Then this line changes the player variable, which is not what you need.

You should rename one to something unique and change your code respectively.

1 Like