So basically I want to be able to tell when someone inserts a part using a plugin.
But I dont know how to tell when you do that. So how do I do that?
So basically I want to be able to tell when someone inserts a part using a plugin.
But I dont know how to tell when you do that. So how do I do that?
as far as im certain… u cant, sry
Oh ok. I just had to make sure!
You could from your own plugin in various ways, but from others, it won’t be possible.
game.DescendantAdded:Connect(function(d)
print(d:GetFullName())
end)
Note that this will fire every time something changes Parents, not just when it’s instantiated. You could keep track of instantiated things to avoid duplicate firing like this:
local seenInstances = setmetatable({}, {__mode="k"})
function onPartAdded(part)
print(part:GetFullName())
end
game.DescendantAdded:Connect(function(d)
if d:IsA("BasePart") and not seenInstances[d] then
seenInstances[d] = true
onPartAdded(d)
end
end)
Note that the table should almost certainly have weak keys, otherwise “keeping track of instances” will prevent them from ever being GC’ed. Read more in the manual on “weak tables”.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.