So there are three pads that are in a model, and a ball this is going to fall at the top.
How can I detect which one of the pads has been touched without having to put a script in all of the pads?
I know this is kinda confusing but I need it to work for all three pads, or more (maybe even like 100 parts)
I have an Idea here, in this situation, what I would do is make three functions, then activate them when a specific part is touched, one sec I’ll make a script
Instead of renaming every part manually just iterate through all the parts in your model and attach connections to them within a loop
local model = script.Parent
for i, Part in pairs(model:GetChildren()) do
Part.Touched:Connect(function()
print("The ball touched ".. Part.Name)
end)
end
This here, use this. However make sure that it’s a BasePart before doing Part.Touched because if you have anything else in the model that isn’t a part, it will error.
for _, part in pairs(script.Parent:GetChildren()) do
if part:IsA("BasePart") then
part.Touched:Connect(function()
print("The ball touched "..part.Name)
end)
end
end