When tween in CameraHandler module script is completed gui should be destroyed:
function cameraHandler.reset(location, gui)
local tween = TweenService:Create(camera, SPAWN, {CFrame = location})
tween:Play()
tween.Completed:Connect(function()
camera.CameraType = Enum.CameraType.Custom
gui:Destroy() --gui references to MainMenuGui
end)
end
So now the problem:
The gui is being destroyed as it should be however connections inside scripts are not being disconnected and script.Destroying is not being triggered. Here is the video:
As you can see the connections still trigger print and it says that the source is “Studio”. Note that I’m not using any task functions and coroutine s. I appreciate any help!
Yeah that solves my problem. I created new gui with just local script and module script and problem occurred again.
So I guess I have now 3 solutions for that problem:
place modules inside ReplicatedStorage
hide gui instead of destroying it
manually disconnect events (this one won’t work 100% properly because old modules will still exist they will be just “deactivated” if you disconnect everything)