Y’know how RemoteEvents can only fire from Local to Server and Server to Local? It’s just that but the opposite. BindableEvents can only fire from like-to-like, so only Server to Server and Local to Local.
I usually use them for ModuleScript-like behavior but when using a ModuleScript is too excessive.
Perhaps get a script that controls the effects, and set the parent to the main script. Once the player consumes the item, the effect script will be cloned into the player, and then afterwards, you’ll be free to delete the script.
Make sure at first the effect handler script is disabled, and then reenable the handler within the main script.
So the tree would look like:
Consumable Item → Main Script → Effect Script (Disabled)
Create a ModuleScript under ReplicatedStorage called RunOnDestroy
Put this in the ModuleScript
local Uncon = Instance.new("BindableEvent")
local function runOnDestroy(object: Instance, runfunc)
Uncon:Fire(object, runfunc)
end
Uncon.Event:Connect(function (object: Instance, runfunc)
object.Destroying:Once(runfunc)
end)
return runOnDestroy
In an ordinary script, put something like this:
local onDestroyFunc = require(game:GetService("ReplicatedStorage"):WaitForChild("RunOnDestroy"))
onDestroyFunc(script,
function()
for i = 1, 10 do
print("I'm dying")
end
end)
wait(10)
script:Destroy()
That should work, remember to treat the required module as a function.