1 does not equal 1 for some reason

I am making a guess the character system and I am making it in a unique way. The answers and stage numbers are the names of the doors. The answer and stage number are split with an underscore.

image

The script works by detecting when the player chats and gets the chat. Then it changes the chat to lowercase and removes all spaces. Then it loops through all the objects inside of the stages folder. Then it checks if the object is a model. If the object is a model it splits the answer and stage number. Then it checks if the guess is equal to the answer. Then it checks if the players current stage is equal to the stage number and if it is it will increase the players stage by 1 but for some reason when I tested it nothing printed.

local stages = workspace.Stages:GetDescendants()

game.Players.PlayerAdded:Connect(function(player)
	task.wait()
	local stage = player.leaderstats.Stage
	
	player.Chatted:Connect(function(guess)
		local editedGuess = string.lower(string.gsub(guess, " ", ""))
		print(editedGuess)
		for _, object in pairs(stages) do
			if object:IsA("Model") then
				-- object is a model
				-- get name of model
				local pony = string.split(object.Name, "_")
				local ponyName = string.lower(pony[1])
				local ponyStage = pony[2]
				
				if editedGuess == ponyName then
					print("Correct! Guess: "..editedGuess.." Pony name: "..ponyName)
					print("Stage: "..stage.Value.." Pony stage: "..ponyStage)
					
					if stage.Value == ponyStage then
						print("Stage up!")
					end
				end
			end
		end
	end)
end)

You can do a quick type check in a print statement.

Im guessing ponyStage is a string so you will need

tonumber()
1 Like