I created this pretty neat axe tool which you can swing when you click, I made this bunker here out of welds instead of anchoring it. I want to destroy the bunker by swinging the axe. How would I make it so when the axe touches parts with welds it destroys those welds?
script in handle:
local handle = script.Parent
handle.Touched:Connect(function(hit)
local items = hit:GetDescendants()
for _, item: Instance in items do
if item:IsA("Weld") or item:IsA("WeldConstraint") then
item:Destroy()
end
end
end)
this will break any welds anytime the axe is touched. You could instead move this code into the swinging script and add a connection and when the swing is over, disconenct the .Touched connection
Should work but I think you can simplify it using the break joints function
https://developer.roblox.com/en-us/api-reference/function/BasePart/BreakJoints
oh I thought that was only a model thing. My bad, but if OP is using a weld constraint for this stuff then my solution would most likely work best.
but that also is a good solution
Yeah, I am using weld constraints but the other guy’s solution would work for welds just fine
Thanks!
This solution worked… until other players joined
Now they’re just making eachother go bald! What do I do?
if item:IsA("JointInstance")
Base class for joints.
https://developer.roblox.com/en-us/api-reference/class/JointInstance
if Part:FindFirstAncestor("Bunker") then
Make sure the part belongs to the bunker beforehand.
you can simply do the following:
local handle = script.Parent
handle.Touched:Connect(function(hit)
local items = hit:GetDescendants()
for _, item: Instance in items do
local character = item:FindFirstAncestorWhichIsA("Model")
local player = game.Players:GetPlayerFromCharacter(character)
if not player then
if item:IsA("Weld") or item:IsA("WeldConstraint") then
item:Destroy()
end
end
end
end)