Hello, I was wondering if this code would create a memory leak.
local Car = game.ServerStorage.Car
local function SpawnCar()
local NewCar = Car:Clone()
NewCar.Parent = workspace
end
local function DeleteCar()
workspace.Car:Destroy() -- "New car" is destroyed
end
SpawnCar()
task.wait(10)
DeleteCar()
-- Memory leak?
-- New car is never set to nil but it is being destroyed
-- Module script
local Car = game.ServerStorage.Car
local Module = {}
function Module.SpawnCar()
local NewCar = Car:Clone()
NewCar.Parent = workspace
end
function Module.DeleteCar()
workspace.Car:Destroy()
end
-- Server script
local Module = require(script.Parent)
for i = 1, 100000 do
Module.SpawnCar()
task.wait(10)
Module.DeleteCar()
end