As of recently, whenever I have tried to call math.huge within a variable, my Roblox Studio would crash immediately after running the game.
I can confirm this as I have replaced the math.huge with a normal number like “10000”, ran the game and it didn’t crash. It also immediately crashed once again shortly after I put math.huge back.
What happened to math.huge? I sharply remember how it didn’t used to crash my Roblox Studio before. If you have answers it would be much appreciated.
Can you give me an example script where this happens?
This doesn’t sound like a math.huge issue, as math.huge is usually just a value, but an issue somewhere else that uses math.huge. I’m certain that Roblox did not change math.huge out of the blue.
The initial variable is empty, but the variable would be set to math.huge every 0.1 seconds in a while true do loop yes.
(It’s pretty confusing as I have run this script without crashing before, so it would be pretty weird if all of a sudden putting this in a loop is the reason it’s crashing)
local collection = game:GetService("CollectionService")
local zombie = script.Parent
local zombieHRP = zombie.PrimaryPart
local humanoid = zombie:WaitForChild("Humanoid")
local myTag = collection:GetTags(zombie)[1]
local currentTarget
local closestDistance
while true do
task.wait(.1)
closestDistance = math.huge
currentTarget = nil
local inRange = workspace:GetPartBoundsInRadius(zombieHRP.Position, closestDistance)
for i,v in ipairs(inRange) do
if not v.Parent:FindFirstChild("HumanoidRootPart") then continue end
if collection:GetTags(v.Parent)[1] == myTag then continue end
local distance = (v.Parent.PrimaryPart.Position - zombieHRP.Position).Magnitude
if distance < closestDistance then
closestDistance = distance
currentTarget = v.Parent
end
end
if currentTarget then
humanoid:MoveTo(currentTarget.HumanoidRootPart.Position)
else
humanoid:MoveTo(zombieHRP.Position)
end
end