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

How do I weld a Union to a player's torso?

Asked by 6 years ago

So I've seen some scripts/videos of people creating a block they want in the script, like sizing it, making it the right color ect and then welding it to a player but I would like to weld a specific (slightly complicated) union to a player. Like the Union is already in workspace im just not sure how to get it to weld to player

3 answers

Log in to vote
0
Answered by
wookey12 174
6 years ago
game.Players.PlayerAdded:connect(function()
    local Weld = Instance.new("Weld", game.Players.LocalPlayer.Backack.Union) --put the union in starterPack
    Weld.Part0 = Weld.Parent
    Weld.Part1 = game.Players.LocalPlayer.Character.Torso
    Weld.C0 = CFrame.new(0,0,0) * CFrame.Angles(0,0,0) --position the union
end)
0
For future reference it's "Backpack" instead of "Backack" Skeleton8909 0 — 6y
0
what was the point of your message. i know its backpack, i just made a mistake. wookey12 174 — 6y
Ad
Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago

First we create a weld instance

local w = Instance.new("Weld")

Then we add which two parts its welded between

w.Part0=character.Torso
w.Part1=union

Then we can change the way its connected to it, like back one stud up one stud rotated this

w.C0=CFrame.new(0,1,0)*CFrame.Angles(math.rad(90),0,0)--up 1 stud rotated 90 on the x axis

Then we parent the weld, usually to the Part0

w.Parent=character.Torso

Let's put it together

local w = Instance.new("Weld")
w.Part0=character.Torso
w.Part1=union
w.C0=CFrame.new(0,1,0)*CFrame.Angles(math.rad(90),0,0)
w.Parent=character.Torso

more info

0
It says attempt to index glocal "character" (a nil value) however so like it's not finding the chracter? ipwnjustinn 0 — 6y
0
one way to make it one line shorter(if you REALLY wanted to) would to add a comma after "Weld" in the instance then put the address of the parent wookey12 174 — 6y
0
my script didn't include the character and union variables DanzLua 2879 — 6y
0
@wookey12 You shouldn't be doing that when you are going to change the properties of the instance DanzLua 2879 — 6y
View all comments (2 more)
0
@DanzLua you still can change the properties of weld (w.Part0, w.Part1,etc.) it just makes it shorter wookey12 174 — 6y
0
@wookey12 Making the code shorter isn't everything, you also have to think about efficiency. http://devforum.roblox.com/t/psa-dont-use-instance-new-with-parent-argument/30296 DanzLua 2879 — 6y
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

If you want too make a part get connected to the torso then

IF R15 game:

--Put this in a script inside ServerScriptService
--Put the Union inside the ServerStorage
game.Players.PlayerAdded:connect(function(plr) --Function when a player joins
    plr.CharacterAdded:connect(function(char)
        --Now that the function is done, now what, we have to weld the part/union
        local w = Instance.new("ManualWeld")
        w.Part0 = char.UpperTorso --Replace UpperTorso to LowerTorso to get the LowerTorso
        local union = game:GetService("ServerStorage").Union:Clone() --rename what the union name --is
        union.Parent = char
        w.Parent = plr.Backpack
        w.C0 = CFrame.new(0,0,0) --Change the value you want
    end
end

Answer this question