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

Welding when Player Joins won't Work?

Asked by
Spoookd 32
9 years ago

I am trying to weld a part to a player when they join the game, but it only happens to one person. Unless starting servers from roblox studio is messed up, because I put 2 players in, and on Player 2's screen, Player 1 has the part welded to him, but Player 2 doesn't. Then if I go onto Player 1's screen, none of them have it. Plus I look at the server window and in the output it says "An error occurred" Here is the script:

01local function weldBetween(a, b)
02print(a, b)
03    local weld = Instance.new("ManualWeld", a)
04    weld.Part0 = a
05    weld.Part1 = b
06    weld.C0 = b.CFrame:inverse() * b.CFrame
07a.LocalTransparencyModifier = 0
08    a.Parent = b
09    return weld
10end
11 
12game.Players.PlayerAdded:connect(function(plr)
13    plr.CharacterAdded:connect(function(chr)
14        local part = Instance.new("Part", game.Workspace)
15        part.Name = "Welded Part"
16        part.Size = Vector3.new(2,2,2)
17local weld = weldBetween(part, chr.Torso)
18    end)
19end)

Answer this question