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

Remove possible welds from a part? (hit)

When a part touched another part (lava) all welds that are attached to the part get destroyed

example - an unanchored car hits a rock and the part that touched the rock falls of the car ( like in those old 2010 games )

the car is welded together so it doesn't fall apart.

v - the script ( lava part ) - v

script.Parent.Touched:Connect(function(hit)
local all = hit:FindFirstChild("Weld")
	all:Destroy()
end)

I could just make the part disappear with a script, but that's lame.

2 answers

✓ Accepted answer
script.Parent.Touched:Connect(function(hit)
	local all = hit:FindFirstChildOfClass("Weld") or hit.Parent:FindFirstChildOfClass("Weld")
	repeat
	all = hit:FindFirstChildOfClass("Weld") or hit.Parent:FindFirstChildOfClass("Weld")
	if all then
		all:Destroy()
	end
	until all == nil
end)

I haven't tested it but maybe it would work

2 comments

0

Nice, works, but quick question - how to make the script ignore if a human touches it? Please scroll down this post and see my answer. my fix didn't work.

0

Nice, works, but quick question - how to make the script ignore if a human touches it? Please scroll down this post and see my answer. my fix didn't work.

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid ~= nil then
		return
	else
    local all = hit:FindFirstChildOfClass("Weld") or hit.Parent:FindFirstChildOfClass("Weld")
    repeat
    all = hit:FindFirstChildOfClass("Weld") or hit.Parent:FindFirstChildOfClass("Weld")
    if all then
        all:Destroy()
    end
    until all == nil
end
end)

1 comment

0

u basically took my post and added on to it but ok

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