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

Welding script help?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

I have a normal script in ServerScriptService: When a person joins they have a backpack on but when they die, they loose it. I want it to always stay on them after they die or whatever happens.

--This is front backpack

game.Players.PlayerAdded:connect( --When a player joins the game
    function(plr)
        plr.CharacterAdded:connect( --When his character spawns
            function(char)
                local tors = char:WaitForChild('Torso') --tors is the character's Torso
                local backpack = workspace.Backpack:Clone() --Define backpack as a part
                local weld = Instance.new('Weld',tors) --Create a new weld object inside tors
                weld.Part0 = tors --A weld needs 2 parts to funciton, this is one of them
                weld.Part1 = backpack.Part --This is the other one
                weld.C0 = CFrame.new(0,0,1) --Offset it 1 stud backwards
                backpack.Parent = char --Parent it to the character
            end
        )
    end
)

Answer this question