If statement not working but it is true

I have been trying figure out what was wrong with my code for quite a long time now, and I still do not know why this one if statement will not work even though it is true.
Here is the code:

for place , frame in pairs(Winners) do
		local Actualplace = string.split(place, "")[string.len(place)]
		print(Actualplace)
		for _, plr in pairs(game.Players:GetPlayers()) do
			local MainFrame = ServerStorage.BindedFunc.WaitForGUISERVER:Invoke(plr)

			if frame then
				local Cframe = frame:Clone()
				Cframe.Parent = MainFrame.Winners[Actualplace]
				for Num, Pos in pairs(TweenLocationsToPlace) do
					print(Num..Actualplace)
					Actualplace = string.split(place, "")[string.len(place)]
					if Actualplace == Num then
						print("Playing?") --Does not print playing. This if statement does not run.
					end
				
					print(Num.." "..Actualplace) --print 3 3 , 2 2 , and 1 1 but the if statement still does not run.
				end
			end
		end	
	end 

Here is what the tables are equal to:
Winners :

local placesName = {
		["player1"] = 1;
		["player2"] = 2;
		["player3"] = 3;
	}

TweenLocationsToPlace :

	[1] = UDim2.new(0.285,0,-0.12,0);
	[2] = UDim2.new(0.011,0,1.5,0);
	[3] = UDim2.new(0.56,0, 1.5,0)

Thanks for your help! :grinning:

1 Like

Could you try printing what the Actualplace variable is? Maybe that could be the reason why perhaps

The actual place variable is equal to the number in player1, player2, and player3. So it equals 1, 2, or 3. Because it goes through a loop it equals all 3 of those numbers just at different times.

Hm just to check & make sure, could you use the tonumber() on the Actualplace variable just to be sure that it truly is a number value? & not a string?

1 Like