-
What do you want to achieve?
I am using RunService.Heartbeat to simulate dynamic flight behavior in a quadcopter drone mesh for an airshow. It uses math.noise() to generate random trajectories in a loop.
Model Link: Drone (Needs Fixing) - Roblox -
What is the issue?
It flies fine, but after a while, it randomly deletes itself. The interval between the disappearance is inconsistent, ranging from a few seconds to several minutes. But the final CFrame printed is a constant. My best guess is it keeps reaching a specific value that the game can’t handle, flinging it to oblivion. No error message appears; just a silent vanishing act.
Normal Flight Behavior: (https://gyazo.com/1500eb4fc126ce610943fa3030472cc1)
Output Warning: (Screenshot by Lightshot) -
What solutions have you tried so far?
I’ve tried changing the min-max random number range, the frequency decimal, the mesh’s collisions, adding a BodyGyro, and even replacing Heartbeat with Stepped. Its annihilation is inevitable, always ending with the same number (-3.40282347e+38).
local RunService = game:GetService("RunService")
local part = script.Parent
local center = part.Position
local radius = 20
local freq = 0.001
local lastPosition = part.Position
local ox = math.random(1,500)
local oy = math.random(1,500)
local oz = math.random(1,500)
local function Update()
local now = time() % 1000000
local noiseX = math.noise(now + ox * freq) * radius
local noiseY = math.noise(now + oy * freq) * radius
local noiseZ = math.noise(now + oz * freq) * radius
if noiseX ~= 0 and noiseY ~= 0 and noiseZ ~= 0 then
local newPosition = center + Vector3.new(noiseX,noiseY,noiseZ)
part.CFrame = CFrame.lookAt(newPosition, newPosition + (lastPosition - newPosition).Unit)
lastPosition = newPosition
end
end
RunService.Heartbeat:Connect(Update)