Why does this happen?

The only code that is running in the game is a while loop.

while loop
    local function gameplay()
        -- code
    end

    -- gameplay ends
     gameplay = nil -- to garbage collect it
   wait(2)
end

This blueprint does not provide us with enough information about what’s causing the issue. Care to share the full code?

1 Like

Ideally you shouldn’t be defining a function within a while-loop. Can you define it outside and call it within the loop instead to see if that helps your memory usage?

I don’t understand what your doing with this code. All your doing is defining the same function over and over again, your not even calling it. And setting a variable to nil.