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
8 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:

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) 

Answer this question