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

Help with weld script?

Asked by
FiredDusk 1466 Moderation Voter
7 years ago

When a player joins, they should have the part stuck to them. There is no weld in the part either.

local Part = script.Parent

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
        local Torso = char:WaitForChild("Torso")
        local Weld = Instance.new("Weld")
        Weld.Part0 = Torso
        Weld.C0 = Torso.CFrame:inverse()
        Weld.Part1 = Part
        Weld.C1 = Part.CFrame:inverse()
        Weld.Parent = Part
        Part.Anchored = false
    end)
end)
0
Do you think it's getting stuck on the WaitForChild? dragonkeeper467 453 — 7y
0
Not sure. FiredDusk 1466 — 7y

1 answer

Log in to vote
0
Answered by
ferano 0
7 years ago

Here is an example of what you are trying to do. Play around with positioning, for the purpose of this it is named shieldpart.

--PUT THIS IN STARTER GUI, SHOULD BE A LOCALSCRIPT

wait()

player = game.Players.LocalPlayer
character = player.Character
leftarm = character["Left Arm"]

shieldpart = game.Workspace.Shield
local shield = shieldpart.ShieldHandle

if shieldpart.Parent ~= character then
shieldpart.Parent = character

local weld = Instance.new("Weld", shield)
weld.Part0 = leftarm
weld.Part1 = shield
weld.C0 = CFrame.new() * CFrame.fromEulerAnglesXYZ(0,0,0)
end
0
I don't want a local script. FiredDusk 1466 — 7y
0
Why? Just make a parent script and clone the script into the players starter pack if it means that much ferano 0 — 7y
Ad

Answer this question