I have two scripts they each look like this:
"function onTouched(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then local DarkGreen = workspace.DarkGreen DarkGreen:Destroy() end end
script.Parent.Touched:connect(onTouched)" but I want them to work on grouped parts not separately. How do I do this or can I?
Hello there!
First off, use code blocks, they really help.
And about your problem. From what I've understood, I see that you are trying to trigger a function whenever a player touches a model. If that is the case, you can use for i,v in pairs.
So it'd be like :
for i,v in pairs(your model's location here, for example, game.Workspace.Model:GetChildren()) do --So we used :GetChildren() function which gets the children of a parent if the parent has any children. --Now, we are going to do: v.Touched:connect(function() --Your code here end) end
If I got it wrong, you can tell me what's the case. I didn't really understand much because your text seems unorganized.
So, overall, we used "v" as of the children of the model inside workspace. If we want to do something to the children of the model, we use v.
Then you can do anything with you want. For example:
v.Touched:connect(function(hit) print(hit.Name) end
So what this does is, whenever something touches the model, it prints it's name.
I think I get it thank you :) I will play around with that for a bit and see where it goes and I will be sure to organize my questions better in the future thank you xD the destruction of grouped parts will be done >: ) muahahaha