Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make multiple parts and they all have the same value?

So i am trying to make like a tool that destroys parts when clicked an amount of times and i have a part named MinePart but i have like 50 of them with the same name the same intvalue because its like a mining game but it only shows up for 1 of the parts and not any others i really need help i have no idea what to do heres my script:

local Tool1 = script.Parent local Tool1Damage = script.Parent.Folder.Tool1Damage Tool1Damage.Value = 1

local MinePart = game.Workspace:FindFirstChild("MinePart") local Health = MinePart.Folder:FindFirstChild("Health") Health.Value = 15

Tool1.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if mouse.Target and mouse.Hit then if mouse.Target == MinePart then Health.Value = Health.Value - Tool1Damage.Value if Health.Value <= 0 then MinePart:Destroy() end end end end) end)

1 comment

0

I think your problem is using the ":FindFirstChild" event. This script will only apply to the first part named "MinePart". Use ":GetChildren()" instead?

1 answer

✓ Accepted answer

you would want to make a identifier if the block is a block or just part of the map after that just check if the part has the identifier

local Tool1 = script.Parent local Tool1Damage = script.Parent.Folder.Tool1Damage Tool1Damage.Value = 1

local MinePart = game.Workspace:FindFirstChild("MinePart") local Health = MinePart.Folder:FindFirstChild("Health") Health.Value = 15

Tool1.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() if mouse.Target and mouse.Hit then if mouse.Target:FindFirstChild("Identifer") then --if it can find the identifer then set the part to Mouse.Target
local Part = Mouse.Target
Health.Value = Health.Value - Tool1Damage.Value 
if Health.Value <= 0 then Part:Destroy()
 end
 end 
end 
end)
 end)

2 comments

0

what would the identifer be like a part or something and would you name the identifer "identifer" and what Part are you reffering to when you put local Part = mouse.Target

0

the identifer make sure it is a part not just any map parts thats not suppose to be destroyed

This discussion is preserved as it was. New answers, comments, and votes are closed.