<= Not Working for Some Reason

ok idk why but this just isn’t working. it works when i take out the <= maxenergy though.

local maxenergy = 100

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local energy = player.Data.Energy
		
		if energy.Value <= maxenergy then
			energy.Value = energy.Value + 15
			script.Parent:Destroy()
		end
	end
end)
1 Like
if energy.Value <= maxenergy then
   energy.Value = energy.Value + 15
   script.Parent:Destroy()
else if energy.Value >= maxenergy then
   warn("This human has more than enough energy! Current energy is " .. energy.Value)
   return
end

The code runs, check if energy.Value is lower or equal to maxenergy. If energy.Value is lower or equal to maxenergy, then give the player plus 15 energy.Value.

This won’t work if the player has more than 100 energy.Value though, so it an expected behaviour.