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

How to check if tool name and a string value is the same?

Not sure if I'm doing this the right way. I'm getting stuck at if v2.Name == v.Value

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if player:WaitForChild("swordBackpack")then
			if player.swordBackpack then
				local swordList = player.swordBackpack:GetChildren()
				for i,v in pairs(swordList) do
					if v:IsA("StringValue") then
						if game.ReplicatedStorage.SWORDBANK then
							local swordbank = game.ReplicatedStorage.SWORDBANK:GetChildren()
							for i,v2 in pairs(swordbank) do
								if v2:IsA("Tool") then
									if v2.Name == v.Value then
										print(v)
									end
								end
							end
						end
					end		
				end
			end	
		end
	end)
end)

1 answer

✓ Accepted answer

Make sure you are using a script and not a local script.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		local SwordPack = player:WaitForChild("swordBackpack")
		local Swords = {}
		for _,SwordChild in pairs(SwordPack:GetDescendants()) do
			if SwordChild:IsA("StringValue") then
				table.insert(Swords,SwordChild)
			end
		end
		local Swordbank = game.ReplicatedStorage:WaitForChild("SWORDBANK")
		for _,Bank in pairs(Swordbank:GetDescendants()) do
			if Bank:IsA("Tool") then
				for i,Sword in pairs(Swords) do
					if Bank.Name == Sword.Value then
						print(Sword.Value)
					end
				end
			end
		end
	end)
end)

1 comment

0

I needed to look for the name of the stringValue instead of its value, so my scripts actually worked lol... thanks though this looks a lot neater

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