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?