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

How would I weld the front surface of a part to the player's back? [CLOSED]

Asked by 3 years ago
Edited 3 years ago

I want to make a bag welded to the back of the player, and I can't think of how to do so. I have tried using cframes like :

while wait() do
script.Parent.CFrame = script.Parent.Parent.Parent.HumanoidRootPart.CFrame*CFrame.new(0,0,1) 
end

I tried welding the part to the humanoid root part :

local weld = Instance.new("Weld", script.Parent)
weld.Part0 = script.Parent.Parent.Parent.HumanoidRootPart
weld.Part1 = script.Parent

and nothing worked. I probably am making a dumb mistake but any help is appreciated. Thanks for your time

1 answer

Log in to vote
0
Answered by 3 years ago

I'm not sure if this is correct but you can give it a try and if it doesn't work then please respond and tell me your problem.

--//This is a script not a local script!!
local backPack = --//Path to backpack

local function givePack(plr)
    local char = plr.Character or plr.CharacterAdded:Wait()
    repeat wait() until plr.Character

    local humRoot = char:WaitForChild("HumanoidRootPart")

    local newBack = backPack:Clone()
    newBack.CFrame = CFrame.new(humRoot.CFrame - Vector3.new(0,0,newBack.Size.Z))
    local weld = Instance.new("WeldConstraint")

    weld.Parent = newBack
    weld.Part0 = newBack
    weld.Part1 = humRoot
end)
game.Players.PlayerAdded:Connect(function(plr))
    givePack(plr)
    repeat wait() until plr.Character == nil
    givePack(plr)
end)

I'm really sorry if this doesn't work. If so then please reply to this answer and I'll see what I can do to fix it!

0
This is exactly what I wanted! I just made a small adjustment in the CFrame equation that you put, and it gave me the exact result I wanted. Thanks! BrainDead_Dev 135 — 3y
0
Great! I'm glad to hear that! kingblaze_1000 359 — 3y
0
Great! I'm glad to hear that! kingblaze_1000 359 — 3y
0
Great! I'm glad to hear that! kingblaze_1000 359 — 3y
View all comments (4 more)
0
Great! I'm glad to hear that! kingblaze_1000 359 — 3y
0
Great! I'm glad to hear that! kingblaze_1000 359 — 3y
0
Great! I'm glad to hear that! kingblaze_1000 359 — 3y
0
Great! I'm glad to hear that! kingblaze_1000 359 — 3y
Ad

Answer this question