Doesn't print when a tool has the same name as a value

I would like to print something when a tool in the players backpack has the same name as a number. The issue is that when i try to check if the tool has the same name as the number nothing gets printed.

Here is the script that i have made

winner = 1
	
	for _,player in pairs(players:GetPlayers()) do
		local tool = player.Backpack:FindFirstChildWhichIsA('Tool') or player.Character:FindFirstChildWhichIsA('Tool')
		print('player has tool') --this gets printed
		if tool.Name == winner then --I have also tried -> if tool == winner then
			print('zoo wee mama') --this does not
		end
	end

Not sure if this will make much of a difference, but could you try wrapping winner with tostring()?

if tool.Name == tostring(winner) then
-- ...

is the tool named “1”? you should consider changing it into something else.

For now it is named “1” later it will be named something else

This worked. Big thank youuuuuuuu🥰

yeah since winner was an number and not a string and so turning the 1 into a string would work

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