Skip to content

Commit 1ae36f5

Browse files
Merge pull request #49 from Metallochrome/disconnect
fix: Added disconnect to stop function
2 parents 70e7979 + 3605500 commit 1ae36f5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src-build/init.luau

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ function Class.Start(): { Stop: () -> () }
645645
SB_UNINDENT_LOG()
646646
end
647647

648-
CollectionService:GetInstanceAddedSignal("SmartBone"):Connect(SetupObject)
648+
connection = CollectionService:GetInstanceAddedSignal("SmartBone"):Connect(SetupObject)
649649

650650
for _, Object in CollectionService:GetTagged("SmartBone") do
651651
SetupObject(Object)
@@ -681,6 +681,11 @@ function Class.Start(): { Stop: () -> () }
681681
for _, Actor: Actor in ActorFolder:GetChildren() do
682682
Actor:SendMessage("Destroy")
683683
end
684+
685+
if connection then
686+
connection:Disconnect()
687+
connection = nil
688+
end
684689
end,
685690
}
686691
end

src/init.luau

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ function Class.Start(): { Stop: () -> () }
645645
SB_UNINDENT_LOG()
646646
end
647647

648-
CollectionService:GetInstanceAddedSignal("SmartBone"):Connect(SetupObject)
648+
connection = CollectionService:GetInstanceAddedSignal("SmartBone"):Connect(SetupObject)
649649

650650
for _, Object in CollectionService:GetTagged("SmartBone") do
651651
SetupObject(Object)
@@ -681,6 +681,11 @@ function Class.Start(): { Stop: () -> () }
681681
for _, Actor: Actor in ActorFolder:GetChildren() do
682682
Actor:SendMessage("Destroy")
683683
end
684+
685+
if connection then
686+
connection:Disconnect()
687+
connection = nil
688+
end
684689
end,
685690
}
686691
end

0 commit comments

Comments
 (0)