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

Welded Part is Invisible?

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" and both of the players have it on. 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)

1 answer

Log in to vote
0
Answered by 9 years ago

I'm not sure what exactly is wrong, but I spotted few mistakes. It should work fine once fixed.

01local function weldBetween(a, b)
02    print(a, b)
03    -- Why use manualWeld? Just use regular one
04    local weld = Instance.new("Weld", a)
05    weld.Part0 = a
06    weld.Part1 = b
07    -- You inversed b cframe and multiplied with b cframe, which would result into empty CFrame
08    -- instead, inverse origin and multiply with other cframe
09    weld.C0 = a.CFrame:inverse() * b.CFrame
10 
11    -- Not sure where you were going with these lines, especially parenting a part to b
12    -- a.LocalTransparencyModifier = 0
13    -- a.Parent = b
14    return weld
15end
View all 28 lines...
0
I tried it and it didn't work. The part just sits on the baseplate Spoookd 32 — 9y
0
It would weld the part based on where it was when player spawned. Also, might need to add wait for child there. ZarsBranchkin 885 — 9y
0
Where do I need to put waitforchild? Spoookd 32 — 9y
0
I already updated the script, it wait's for torso. ZarsBranchkin 885 — 9y
Ad

Answer this question