Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Remove possible welds from a part? (hit)

Asked by
14dark14 167
5 years ago

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

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

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

2 answers

Log in to vote
1
Answered by 5 years ago
1script.Parent.Touched:Connect(function(hit)
2    local all = hit:FindFirstChildOfClass("Weld") or hit.Parent:FindFirstChildOfClass("Weld")
3    repeat
4    all = hit:FindFirstChildOfClass("Weld") or hit.Parent:FindFirstChildOfClass("Weld")
5    if all then
6        all:Destroy()
7    end
8    until all == nil
9end)

I haven't tested it but maybe it would 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. 14dark14 167 — 5y
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. 14dark14 167 — 5y
Ad
Log in to vote
0
Answered by
14dark14 167
5 years ago
Edited 5 years ago
01script.Parent.Touched:Connect(function(hit)
02    local humanoid = hit.Parent:FindFirstChild("Humanoid")
03    if humanoid ~= nil then
04        return
05    else
06    local all = hit:FindFirstChildOfClass("Weld") or hit.Parent:FindFirstChildOfClass("Weld")
07    repeat
08    all = hit:FindFirstChildOfClass("Weld") or hit.Parent:FindFirstChildOfClass("Weld")
09    if all then
10        all:Destroy()
11    end
12    until all == nil
13end
14end)
0
u basically took my post and added on to it but ok HappyTimIsHim 652 — 5y

Answer this question