Tool giver system sometimes not giving tool?

Ok, this is a weird one. So I have this tool giver system that inserts tools into the player’s StarterGear and Backpack when they join. But thing is, is that it doesn’t always give the player the tool.

The script even prints when the tool is being inserted, but the tool sometimes doesn’t get added, as shown below:

ignore error, its an old tool script
image

Does anyone know why this is happening? Some help will be greatly appreciated as always. Thank you!

Script:

Players = game:GetService("Players")
RS = game:GetService("ReplicatedStorage")

ToolsFolder = RS:WaitForChild("StarterTools")

-- Accessing StarterGear from Server Script

function onPlayerAdded(player)
	local starterGear = player:WaitForChild("StarterGear")
	local backpack = player:WaitForChild("Backpack")
	for i, Tool in ipairs(ToolsFolder:GetChildren()) do
		local NewTool = Tool:Clone()
		NewTool.Parent = starterGear
		local NewTool2 = Tool:Clone()
		NewTool.Parent = backpack
		print("Gave " .. Tool.Name .. " to " .. player.Name)
	end
end

Players.PlayerAdded:connect(onPlayerAdded)

for i, v in next, Players:GetPlayers() do
	onPlayerAdded(v)
end

can you see the backpack icon in the hotbar?

1 Like

As mentioned here, it does sometimes work.

Which means it is visible

@Ethanthegrand14 bruh u can simply add the tools in starter pack, can’t you?

I am not using the starter pack for several reason.

The main reason being is that I cannot remove items from the starterpack locally. As I have a delete tool button for players.

Thats quite a dumb issue, it can be fixed by doing the following:
switching from:

local NewTool = Tool:Clone()
NewTool.Parent = starterGear
local NewTool2 = Tool:Clone()
NewTool.Parent = backpack

to

local NewTool = Tool:Clone()
NewTool.Parent = starterGear
local NewTool2 = Tool:Clone()
NewTool2.Parent = backpack
2 Likes

you can use RemoteEvents, FireClient/FireAllClients…

1 Like

It’s a server script, so it should work no matter what.

Oh, that’s my fault. Thank you for pointing that out.

Also it seems to have fixed the issue. Thank you!

1 Like