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
What is the issue? Include screenshots / videos if possible!
Does not work. No errors in console.
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)
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.
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.