Should I disconnect this event?

In a local script, under PlayerGui, I have a gui object, and in it I have this event…

	if input.UserInputType == Enum.UserInputType.MouseMovement then
	elseif input.UserInputType == Enum.UserInputType.Touch then

When the character resets, the PlayerGui objects are destroyed.
So, will this event need a disconnect somewhere, considering it is attached to UserInputService?

And if I do need to disconnect it, where and how would I do this?

I tried to assign it a varaible…

 local event = UserInputService.InputChanged:Connect(function(input) ... 

then check for

game.Players.LocalPlayer.CharacterRemoving:Connect(function() event:Disconnect() end)

however, when I reset, the output told me ‘event’ was a nil value.

when a script is destroyed all events in said script are disconnected

Oh yes… now that you say that, I remember reading that once. I guess I am a bit rusty with my events.
Thank you so much.

1 Like