Automatically gives tools based on team

  1. What do you want to achieve? Keep it simple and clear!
    I’d like to have it so when a player is on a specific team, they get the tools for that team. I made it so the tools are directly under the team (in game.teams). The script is supposed to clone the tools under those, and put them in the player’s backpack & starter tools. It also clears the previous items in the starter tools to prevent them from having other items from other teams

  2. What is the issue? Include screenshots / videos if possible!
    Does not work. No errors in console.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Have tried to look at other posts similar & take solutions from there, but it didn’t work out

game.Players.PlayerAdded:Connect(function(plr)
	plr:GetPropertyChangedSignal("Team"):Connect(function()
		local Delete = plr.StarterGear:GetChildren()
		Delete:Destroy()
		for i,v in game.Teams[plr.Team]:GetChildren() do
			if v:IsA("Tool") then
				v:Clone(plr.Backpack)
				v:Clone(plr.StarterGear)
				print("Gave "..v.Name.." to "..plr.Name.." in their Backpack & StarterGear")
			end
		end
	end)
end)

{BEFA3D63-3B8C-4B65-96C4-B484585970DF}

1 Like
game.Players.PlayerAdded:Connect(function(plr)
	plr:GetPropertyChangedSignal("Team"):Connect(function()
		plr.StarterGear:ClearAllChildren
		for i,v in ipairs(plr.Team:GetChildren()) do
			if v:IsA("Tool") then
				v:Clone().Parent = plr.Backpack
				v:Clone().Parent = plr.StarterGear
				print("Gave "..v.Name.." to "..plr.Name.." in their Backpack & StarterGear")
			end
		end
	end)
end)

this most likely still doesn’t work, just slapped it together where I saw mistakes, chuck some print statements in there to see where its still failing.

2 Likes

no it surprisingly works, the player just needs to get respawned for some reason then they get all the tools

That would suggest that the backpack thing doesn’t work, but the starter pack thing kicks in. id make it so it waits until the character exists or something before adding stuff to the backpack, and that should solve it.

What I did is just instantly respawn the player 2-3 seconds after they join, barely noticeable & no need to do anything more than that

But that could fix it too

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