Special tools when in Different Teams Script (Not Working)

Hi, I have a script that gives different tools when on different teams. For example, red team gets this weapon and blue team gets a different weapon.But the script won’t work, can someone please help me out? Any help is appreciated, thanks!

Here’s how it looks like,
image
image
image image
HelpMe.rbxl (316.9 KB)

Script:

local players = game:GetService("Players")

players.PlayerAdded.Connect(function(p)
	p.CharacterAdded:Connect(function(Char)
		local Folder = script:FindFirstChild(p.TeamName)
		if Folder then
			--If team has spawn tools
			local Tools = Folder:FindFirstChild("Tools")
			if Tools then
				--Goes through the tools
				for i,v in pairs(Tools:GetChildren())do
					--Puts in user inventory when made copy
					v:Clone().Parent = p.Backpack
				end
			end
		end
	end)
end)

Try doing p.Team.Name instead of p.TeamName since TeamName is not a property.

Hi, I’ve followed what you said but the script still wouldn’t function.

local players = game:GetService("Players")

players.PlayerAdded.Connect(function(p)
	p.CharacterAdded:Connect(function(Char)
		local Folder = script:FindFirstChild(p.Team.Name)
		if Folder then
			--If team has spawn tools
			local Tools = Folder:FindFirstChild("Tools")
			if Tools then
				--Goes through the tools
				for i,v in pairs(Tools:GetChildren())do
					--Puts in user inventory when made copy
					v:Clone().Parent = p.Backpack
				end
			end
		end
	end)
end)

Can you try adding a print after local Folder printing the value and one after local Tools printing that value and then share the results?

Is this what you wanted me to do?

image

No, I meant it like this.

local players = game:GetService("Players")

players.PlayerAdded.Connect(function(p)
	p.CharacterAdded:Connect(function(Char)
		local Folder = script:FindFirstChild(p.Team.Name)
        print(Folder)
		if Folder then
			--If team has spawn tools
			local Tools = Folder:FindFirstChild("Tools")
            print(Tools)
			if Tools then
				--Goes through the tools
				for i,v in pairs(Tools:GetChildren())do
					--Puts in user inventory when made copy
					v:Clone().Parent = p.Backpack
				end
			end
		end
	end)
end)
1 Like

How do I know the results this script? Do I go in the script output and run the script in the command line?

No, you just replace that with your current code and then open your Output and say what it prints.

1 Like

My bad, I noticed that I had the name of the team wrong and that’s why the script isn’t working. It works fine now. Thanks