thats not how it works.
get descendants litteraly gets descendentS. how do you think it can return multiple values? It returns a table. so basically your script is table.ClickDetector whihc makes no sense. You have to loop through each individual part in the table and look for IT'S click detector. use a simple pairs loop for this.
local trees = workspace.Trees:GetDescendants()
for _,i in pairs(trees) do
i.ClickDetector.MouseClick:Connect(function()
drewno.Value = drewno.Value + 15
wait(1)
end)
end
althought this may work if you script it right (it works for me), its just a better idea to put a script in all those parts themselves and insert a script that says script.Parent.Clickdetector.Mouseclick, then just send over information using a value like a number value or anything that your trying to do.
PS. the reason why creating a clicked function for each part works is because no matter how you declare them, a function will always work from the moment they are delcared to when the game ends or the script with the function ends, so looping through actually creates a new function each time that triggers if it's corresponding part is clicked, simple.
i hope this helps.
3 comments
no mate, cloning same script and putting it into multiple parts is really bad, what if you need to change something, you would have to change all the scripts and it's overall not the best. Also ipairs here would be preferred more. But i liked the agressive post start so i must upvote.
Yea when you do :GetChildren or :GetDescendants you are returning a table of values. For looping them will allow you to edit each individual part
@imKirda you idiot i meant use a SCRIPT to clone it so actually you only need to edit it once