Variable inside player not changing

I have a variable inside the player which should change when the player touches the “Win” part but it does not update and causes the code to run until the player stops touching the part.

The print statement returns true but inside the explorer the variable shows it set to false. This is a server script. I’ve tried making a folder for each player inside ServerStorage as well but the same issue occurs. Same thing if I put it inside leaderstats.

workspace.Map.Win.Trigger.Touched:Connect(function(part)
	if part.Parent:FindFirstChildOfClass("Humanoid") then
		local player = 
			game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
		if player.wonRound.Value == false then
			player.wonRound.Value = true
			print(player.wonRound.Value)
			player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
			startRound()
		end
	end
end)
1 Like

Add a debounce so it will not trigger infinitely.

Is there a possibility that the startRound() function changes the Value back to false? That would explain why it shows up as false after printing true

1 Like

Yes, it does set it back to false, I’m adding debounce right now. Not sure why I didn’t think of this sooner😭

1 Like

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