My Drone's CFrames are Deleting Itself

  1. 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

  2. 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)

  3. 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)

UPDATE: Still haven’t fixed it, but I’ve greatly reduced the instances of it deleting itself. The problem seems to occur whenever the Noise == 0. So I updated the model with a check across each axis before generating a new value. However, on rare occasions it produces an asymptotic decimal (like 0.00000001) that still triggers the purge.

i would use trigonometry instead of noise to make an animation like that. It is more predictable and constant. Something makes the value 0 or different value instead of what it should be.

1 Like

So the ONE thing I hadn’t tried was anchoring the drone mesh, and it’s working perfectly now! I feel silly…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.