This is for a 'fix to vote' script.

function fix()
	for i,v in pairs(game.Players:GetPlayers()) do
		if v:FindFirstChild("Voted for fix?") then
			local a = v:FindFirstChild("Voted for fix?")
			a.Value = false
			print("Reset")
		end
	end
	print("FIXED")
end

--It prints reset and fixed but doesn't set the value of 'a' to false, and doesn't error.

When I press the gui to vote, it works. However when I press it again, it doesn't work because the 'a', or the boolean that checks if you've already voted, doesn't go back to false when the vote at ended, even though on line 5 I set i back to false.

PS - The function gets called later on, everything is defined and "Voted for fix?" is definitely in the player. This is a server script.

5 comments

0

If it's not printing 'Reset' then it's not finding the 'Vote for fix?' value in player, it is coming up nil.

0

--It prints reset and fixed but doesn't set the value of 'a' to false, and doesn't error.

0

try replacing print("Reset") with print("Reset", a.Value). If it prints "Reset false" then everything is working fine and the problem is somewhere else.

0

Hold on I think where the problem is. How do you refer to 'a' in other parts of the script? I'm asking because it might be possible that the Value IS getting changed, but the way you read the value later on in other parts of the script is wrong.

0

I think that when you spam the button that's when it breaks. So I just make the GUI invisible until there are two or more players, then the value will change less frequently, decreasing the chances of it breaking, hopefully...