PlayerAdded dont print

  1. want that playeradded print that

  2. I looked for a solution but i cant find something

local function PlayerAdded(player)
	for i, v in pairs(player:WaitForChild("OwnedTools"):GetChildren()) do
		print(v.Name)
		if player.CurrentTool.Value == v.Name then
			print("Player use tool as current")
			player.Backpack:ClearAllChildren()
			wait(.5)
			local clonedTool = Items:FindFirstChild(player.CurrentTool.Value):Clone()
			clonedTool.Parent = player.Backpack
			clonedTool.Name = player.CurrentTool.Name
		end
	end
end

game.Players.PlayerAdded:Connect(PlayerAdded)

Could you show us the folder when the plader is loaded?

Any errors in the output?

add print("Hi")

under the local function PlayerAdded(player)

that it is like:

local function PlayerAdded(player)
    print("HI")
end

When it is printing “HI”, it is firing

we cant help you more when you are not showing us the folders

You’re doing :WaitForChild("OwnedTools"), and then getting the children of OwnedTools right away. There is a high likelihood that right when it finds the folder, no tools exist in it yet, thus rendering your in pairs loop useless.

If you want to test my theory, add a task.wait(5) right under local function PlayerAdded(player), if it then starts to print the actual tools in the folder, this is your issue. I wouldn’t recommend waiting 5 seconds for actual in game production, I’m simply saying this is a debugging tool you can use.

ok wait i will show you the folders in the player

i will show you the screenshot now

OwnedTools doesn’t have anything in it to begin with, meaning nothing is going to happen. What are you trying to achieve here?

i have buyd some tools and join and nothing prints

Yes, that is expected. You’re checking if you own the tools right when you join, but you don’t have the tools when you join, therefore nothing happens.

i rebirthed that is why i dont have any tools

It won’t print anything unless you have the tools. Do you have the tools when you join?

yes the player have tools when he joins

If you’re doing this in Studio - there’s the chance that the player will load in before the PlayerAdded event can be set up.

Add this before your PlayerAdded Event

for _,plr in pairs(game.Players:GetPlayers()) do
   PlayerAdded(plr)
end

game.Players.PlayerAdded:Connect(PlayerAdded)
1 Like

yes that works thank you for helping me

1 Like

Don’t forget to mark solutions - so that other developers can find answers to similar questions.

ok done your are find the solution