✓ Accepted answer
You have a few options. You can:
Keep the parts in a model and loop through the model
Loop through the workspace and find all objects named tag
Use collection service to tag all the parts and looped thru the tagged parts. This is more for bigger projects with hundreds of items you might not want to have in one model. If you're interested about it, read here for a nice tutorial
#Option 1:
local model = workspace.PartyParts
function onTouched(hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid then
for _, child in pairs(model:GetChildren())do
if child.Name == "Party" then
child.Transparency = 1
child.CanCollide = false
end
end
end
end
script.Parent.Touched:Connect(onTouched)
#Option 2:
function onTouched(hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid then
for _, child in pairs(workspace:GetChidren())do
if child.Name == "Party" then
child.Transparency = 1
child.CanCollide = false
end
end
end
end
script.Parent.Touched:Connect(onTouched)
2 comments
Thank you
np let me know if you need anything else