Hello, I’m having an issue that’s been giving me a headache for a few hours already.
So, I have a collector that collects drops every time it gets touched, this will fire a BindableEvent
to update the values of UIs and such.
[SERVER]
I have debugged and eventually got to these 2 functions:
function Tycoon:PublishTopic(topicName, ...)
self._topicEvent:Fire(topicName, ...)
end
function Tycoon:SubscribeTopic(topicName, callback)
local connection = self._topicEvent.Event:Connect(function(name, ...)
if name == topicName then
callback(...)
end
end)
return connection
end
The :PublishTopic
event creates some sort of memory leak for some reason as seen below.
When I comment the line that fires the event, it seems to no longer increase the rate.
function Collector:OnTouched(hitPart)
local Worth = hitPart:GetAttribute("Worth")
if Worth then
--self.Tycoon:PublishTopic("WorthChange", Worth)
end
end
Also, it seems to work perfectly fine when testing in studio, but when I go in-game, the rate keeps increasing forever.
Does anyone have any idea why this happens? I can’t seem to figure it out.
Any help is appreciated, thanks.