Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Toolgiver script not detecting all tools / giving tools?

Basically my script gives you the tools for a team (Whatever tools are under the team.) But I have 2 issues, 1. Its not giving the players the tool, I can confirm that it does know the correct tool but does not give the player the tool for some reason. 2. It is only detecting one tool in the team, I did some testing and found out that it only detects the first tool under the team. Here is my script:

game:GetService("Players").PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
		for i, v in pairs(game:GetService("Teams"):GetChildren()) do
			if v.TeamColor == plr.TeamColor then
				for a, b in pairs(v:GetChildren()) do
					local Tool = b:Clone()
					Tool.Parent = plr.BackPack
				end
			end
		end
	end)
end)

Issue 1 Lines, 6 - 7. Issue 2 Lines, Unsure, Possibly 5 - 8.

1 answer

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function()
        for i, v in pairs(game:GetService("Teams"):GetChildren()) do
            if v.TeamColor == plr.TeamColor then
                for a, b in pairs(v:GetChildren()) do
                    local Tool = b:Clone()
                    Tool.Parent = plr.Backpack --It was wrong instance.
                end
            end
        end
    end)
end)

Backpack was spelled wrong. You have to write Backpack not BackPack Also ensure that the tools are getting parented to the team.

This discussion is preserved as it was. New answers, comments, and votes are closed.