Why cant the script find this buttion?

I have a vote script for my project but when I try to look for the buttion when the updated vote the buttion comes up nil

for _, updatedPlayer in pairs(game.Players:GetPlayers()) do
			local playerGui = updatedPlayer:FindFirstChild("PlayerGui")
			if playerGui then
				local button = updatedPlayer.PlayerGui.UI.SelectGamemode:FindFirstChild(tostring(option))
				if button and button:FindFirstChild("Count") then
						 -- Ensure Count exists
					local countText = button.Count
					countText.Text = tostring(tonumber(countText.Text) + 1) -- Update Count
				else
					warn('Count not found for option:', option)
				end
			end
		end

Extra Info: The buttion is the Number of which the buttion is like 1 to 3, yes the script can find the playergui

Maybe try just using the local playerGui variable you already have to set the new button variable.

1 Like

I found the solution before you replyed but still thanks for replying!

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