How to make an area where you gain points until you leave?

I want to make an area where you earn points until you leave, with the code I have currently, it doesn’t work.

local humanoid = script.Parent:WaitForChild("Humanoid")

local player = game.Players:GetPlayerFromCharacter(script.Parent)
local leaderstats = player:WaitForChild("leaderstats")
local aliveTime = leaderstats:WaitForChild("Time Alive")
local bestTime = leaderstats:WaitForChild("Best Time")

humanoid.Died:Connect(function()
	if aliveTime.Value > bestTime.Value then
		bestTime.Value = aliveTime.Value
	end
	aliveTime.Value = 0
end)

while wait(1) do
	if humanoid.Health == 0 then
		break
	end
	if humanoid.Parent.HumanoidRootPart.Position = Vector3.new(NumberRange(-300,300),NumberRange(-300,300),NumberRange(-300,300)) then
		aliveTime.Value += 1
	end	
end

Apparently there is an error with using the number range but I don’t know how to fix it, any help?

This is clever, but unfortunately, not how Vector3 works. A Vector3 represents a single position, and can’t represent a range.

Instead, you could test each X, Y, Z component separately:

local pos = humanoid.Parent.HumanoidRootPart.Position

if pos.X > -300 and pos.X < 300 and -- check X component
   pos.Y > -300 and pos.Y < 300 and -- check Y component
   pos.Z > -300 and pos.Z < 300 then -- check Z component
    aliveTime.Value += 1
end