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

What's in this script that makes the vehicle fall apart if the player who was in the seat dies?

Asked by 8 years ago
function onChildAdded(part)
if part.className == "Weld" then
    local torso = part.Part1
    if torso ~= nil then
        local parent = torso.Parent
        if parent ~= nil then
            local player = game.Players:findFirstChild(parent.Name)
            local turret = script.Parent.Parent.Parent.Parent
            turret.Parent = parent
            local tool = script.Turret:Clone()
            tool.Parent = player.Backpack
            script.Parent.Sound:play()
        end
    end
end
end


function onChildRemoved(part)
local player1 = game.Players:findFirstChild(script.Parent.Parent.Parent.Parent.Parent.Name)
player1.Backpack.Turret:remove()
script.Parent.Sound:stop()
end

script.Parent.ChildRemoved:connect(onChildRemoved)
script.Parent.ChildAdded:connect(onChildAdded)

This is the script for it, and if a player gets in the seat, then later dies, it falls apart as if it was exploded. Problem?

1 answer

Log in to vote
1
Answered by
Acheo 230 Moderation Voter
8 years ago

I'm quite well aware of what you're looking for.

This can be performed by inserting the vehicle into the player model such as

Vehicle.Parent = game.Players.Acheo.Character

This will then cause the vehicle (Or model) to break apart as if it were a normal body part.

0
Thanks! Supergamerboy1995 129 — 8y
0
Welcome Acheo 230 — 8y
Ad

Answer this question