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" and both of the players have it on. Here is the script:
local function weldBetween(a, b)
print(a, b)
local weld = Instance.new("ManualWeld", a)
weld.Part0 = a
weld.Part1 = b
weld.C0 = b.CFrame:inverse() * b.CFrame
a.LocalTransparencyModifier = 0
a.Parent = b
return weld
end
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(chr)
local part = Instance.new("Part", game.Workspace)
part.Name = "Welded Part"
part.Size = Vector3.new(2,2,2)
local weld = weldBetween(part, chr.Torso)
end)
end)

4 comments
I tried it and it didn't work. The part just sits on the baseplate
It would weld the part based on where it was when player spawned. Also, might need to add wait for child there.
Where do I need to put waitforchild?
I already updated the script, it wait's for torso.