yeah… im gonna be honest - i have absolutely no clue what to do to fix it
i have a local function in a local script that creates a new part, stores it in local variables, does a bunch of stuff to it and then removes the part after a couple seconds
the memory usage of the script increases every isngle time, to the point of weighing 3mb for no reason after ~5k calls
^^ not sure if related but i get like 40 fps after said 5k calls, and that only gets worse and worse with each and every single execution
so im looking for a way to fix the fps issues and preferably everything else
local function Animate(Piano, PianoNote, isHolding)
local Piano_Keys = Piano.Keys
if PianoNote then
local PianoKey = Piano_Keys:FindFirstChild(tostring(PianoNote))
if PianoKey then
local part
local isPartActive
if animholder:FindFirstChild(PianoNote) and not isHolding then
isPartActive = animholder[PianoNote].Holding
else
part = (IsBlack(PianoNote) and blacknote or whitenote):Clone()
part.Size = Vector3.new(PianoKey.Size.X / 2, 0.1, PianoKey.Size.X / 2)
part.Name = PianoNote
part.Position = Vector3.new(PianoKey.Position.X, PianoKey.Position.Y, PianoKey.Position.Z - (PianoKey.Size.Z / 2))
part.Orientation = Vector3.new(0, PianoKey.Orientation.Y, 0)
part.Anchored = true
part.Transparency = 0
part.Parent = animholder
local temp = Instance.new("BoolValue")
temp.Name = "Holding"
temp.Parent = part
isPartActive = temp
end
isPartActive.Value = true
if isHolding then
task.delay(heldtimeout, function()
if part and part:IsDescendantOf(animholder) then
isPartActive.Parent.Name = "past_" .. tostring(PianoNote)
isPartActive.Value = false
task.delay(deletiontimeout, function()
if part and part:IsDescendantOf(animholder) then
part:Destroy()
end
end)
end
end)
end
task.spawn(function()
while isPartActive.Value do
if isHolding then
part.Position = part.Position + Vector3.new(0, scrollspeed / 2, 0)
part.Size = part.Size + Vector3.new(0, scrollspeed, 0)
else
part.Position = part.Position + Vector3.new(0, scrollspeed, 0)
end
task.wait()
end
end)
if not isHolding then
task.spawn(function()
isPartActive.Parent.Name = "past_" .. tostring(PianoNote)
isPartActive.Value = false
task.delay(deletiontimeout, function()
if part and part:IsDescendantOf(animholder) then
part:Destroy()
end
end)
end)
end
end
end
local connection
connection = Piano.SeatOccupant.Changed:Connect(function(val)
if val == nil then
connection:Disconnect()
for _, v in animholder:GetChildren() do
v.Holding.Value = false
task.delay(deletiontimeout, function()
if v:IsDescendantOf(animholder) then
v:Destroy()
end
end)
end
end
end)
end