Bool value not getting detected

As shown in the title. Whenever I set my boolvalue to true it doesn’t print for some reason. I’ve been getting stressed from this and I still don’t know how to fix it? Any ideas?

game.Players.PlayerAdded:Connect(function(NewPlayer)
	local Disease = Instance.new("BoolValue")
	Disease.Name = "IsInfected"
	Disease.Parent = NewPlayer
	
	local Hygiene = Instance.new("IntValue")
	Hygiene.Name = "Hygiene"
	Hygiene.Value = 100
	Hygiene.Parent = NewPlayer
	
	if NewPlayer.IsInfected.Value == true then
		print("yes")
	end
end)

This won’t detect if you change it after the player has been added.

Try:

NewPlayer.IsInfected.Changed:Connect(function()
	if Isinfected.Value then
		print("Value is true")
	else
		print("Value is false")
	end
end)
1 Like

Change your script to this:

game.Players.PlayerAdded:Connect(function(NewPlayer)
	local Disease = Instance.new("BoolValue")
	Disease.Name = "IsInfected"
	Disease.Parent = NewPlayer

	local Hygiene = Instance.new("IntValue")
	Hygiene.Name = "Hygiene"
	Hygiene.Value = 100
	Hygiene.Parent = NewPlayer
	
	Disease.Changed:Connect(function(isInfected)
		if isInfected then
			print("yes")
		end
	end)
end)

You weren’t detecting the change in the value.

1 Like

Both of the solutions worked thanks