So, I want to make a script that detects if the children of a part has a script inside of it then for example change the part color.
(I just need help with the detect if the children is a part)
So, I want to make a script that detects if the children of a part has a script inside of it then for example change the part color.
(I just need help with the detect if the children is a part)
This may help you : https://developer.roblox.com/en-us/api-reference/function/Instance/IsA
Use GetDescendants
with a for do loop to iterate through the given table and check if it is an LuaSourceContainer
local instance = -- path to instance
for _, Descendant in pairs(instance:GetDescendants()) do
if Descendant:IsA("LuaSourceContainer") then
print(Descendant, "is a script")
end
end
LuaSourceContainer
contains all 3 script classes
BaseScript would suffice (assuming ModuleScripts aren’t being used).
It depends on what the author of the post wants, I chose LuaSourceContainer
in case he wants all 3 types of scripts.
hmmm, doesnt works for me, i tried to use it chaning the path and making a part of the map tps to you but doesnt work
I try to do that
Any error in output? place an print
for _, Descendant in pairs(instance:GetDescendants()) do
print(Descendant)
oh, nvm, that one worked. <3
thanks u