This script is supposed to fire when i clone/change the parent of the script to another, but when i clone the script this doesn’t fire, any ideas why?
local ps = require(game:GetService("ServerScriptService").PocketScripts)
print("test1")
script:GetPropertyChangedSignal("Parent"):Connect(function()
print("test2")
local plr = script.Parent.Parent
for i, theScript in pairs(ps.GetChildrenWhichIsA(plr, "Script")) do
if theScript ~= script then
theScript:Destroy()
end
end
print("nottest")
script.Parent.Value = script.Parent.Value + 60
print("test")
for i = 0, script.Parent.Value, .1 do
task.wait(.1)
script.Parent.Value = script.Parent.Value - .1
print(script.Parent.Value)
end
script.Parent.Name = "1"
script:Destroy()
end)
In the output it printed “test1” but never printed “test2” after i cloned it, help would be appreciated!
The script runs again whenever you change the parent or clone it. This both prevents the event from running and makes the event unnecessary. Just get rid of it.
Okay so turns out there’s nothing wrong with the GetPropertyChangedSignal() function, the script doesn’t work because this script is not Local Script and i set the parent into a Player, resulting in it not printing anything. Changed the script into local and now it works, thank you for the help everyone!