Tools being added first time spawning but not being added after respawning

Hello! My script

print("Hello?")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Folder = ServerStorage:WaitForChild("Fruits")


function AddItems(Character)
	task.wait(1.2)
	print(Character)
	print("Adding Tools")
	local Player = game.Players:GetPlayerFromCharacter(Character)
	for i,v in pairs(Folder:GetChildren()) do
		print("RUNNING RUNNING RUNNING RUNNING")
		local Tool = v:Clone()
		Tool.Parent = Player.Backpack
	end
end

Players.PlayerAdded:Connect(function(player)
	print("PlayerAdded!")
	print("Shuold be adding tools sooon")
	player.CharacterAdded:Connect(AddItems)
end)

Isn’t adding tools to my backpack after I die and respawn, and yes the “RUNNING RUNNING RUNNING” is printing in console,

1 Like

I copied your code in to my studio and made some changes and it seems to work.

print("Hello?")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Folder = ServerStorage:WaitForChild("Fruits")


function AddItems(player)
	task.wait(1.2)
	print("Adding Tools")
	for i,v in pairs(Folder:GetChildren()) do
		print("RUNNING RUNNING RUNNING RUNNING")
		local tool = v:Clone()
		tool.Parent = player.Backpack
	end
end

Players.PlayerAdded:Connect(function(player)
	print("PlayerAdded!")
	print("Shuold be adding tools sooon")
	player.CharacterAdded:Connect(function(character)
		AddItems(player)
	end)
end)
1 Like

Let me try this : )
OnlyTwentyCharacters

sol.1: Put the tool inside StarterPack
sol.2: add “repeat wait() until character”

It did not work, It might be an issue because I have a death screen, but probably not.

For solution 2, that wouldn’t help it’s code specifically waiting for the character to be added, the character wouldn’t be nil if it was added

Does the tool appear when you reset ?

no
OnlyTwentyCharacters23232322323

try this

print("Hello?")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Folder = ServerStorage:WaitForChild("Fruits")


function AddItems(Character)
	task.wait(1.2)
	print(Character)
	print("Adding Tools")
	local Player = game.Players:GetPlayerFromCharacter(Character)
	for i,v in pairs(Folder:GetChildren()) do
		print("RUNNING RUNNING RUNNING RUNNING")
		local Tool = v:Clone()
		Tool.Parent = Player.Backpack
	end
end

Players.PlayerAdded:Connect(function(player)
	print("PlayerAdded!")
	print("Shuold be adding tools sooon")
	player.CharacterAdded:Connect(function() if not player.Character then repeat wait() until player.Character; AddItems(player) end)
end)

If it doesn’t work, then reset and tell me if it works

the issue isn’t the character being added, the for loop is running. It’s just the tools aren’t being added to the backpack

try this

print("Hello?")
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Folder = ServerStorage:WaitForChild("Fruits")


function AddItems(Character)
	task.wait(1.2)
	print(Character)
	print("Adding Tools")
	local Player = game.Players:GetPlayerFromCharacter(Character)
	for i,v in pairs(Folder:GetChildren()) do
		print("RUNNING RUNNING RUNNING RUNNING")
		local Tool = v:Clone()
		Tool.Parent = Player.Backpack
	end
end

Players.PlayerAdded:Connect(function(player)
	print("PlayerAdded!")
	print("Shuold be adding tools sooon")
	player.CharacterAdded:Connect(function(c) if not player.Character then repeat wait() until player.Character; AddItems(c) end)
end)

The issue isn’t the character being added, the issue is the gui for the tools not showing up when the tools are added to the backpack

Oh my, the issue is that my death screen script disbales core gui then doesn’t reenable it.

put this in a local script

wait(game.Loaded)
game:GetService("StarterGui"):SetCoreGuiEnabled("Backpack", true)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.