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

Help w/ weld?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

When a player joins they are suppose to have a model called "Boat" to them. It clones to workspace but not to character :(

game.Players.PlayerAdded:connect(function(plr)
        plr.CharacterAdded:connect(function(char)
                local tors = char:WaitForChild('Torso') --tors is the character's Torso
                local Boat = workspace.Boat:Clone() --Define backpack as a part
                for _,Part in pairs(Boat:GetChildren()) do
                    Part.Anchored=false
                end
                local weld = Instance.new('Weld',tors) --Create a new weld object inside tors
                weld.Part0 = tors --A weld needs 2 parts to funciton, this is one of them
                weld.Part1 = Boat.Part --This is the other one
                weld.C0 = CFrame.new(0,0,0)
                Boat.Parent = char --Parent it to the character
            end)
    end)

1 answer

Log in to vote
4
Answered by 9 years ago

Your main problem may be in line 05-07. If there are other things other than parts in the model, then the script will error. This is only a theory, may not be true. I'm not sure if this will be much help... Here you go anyway. Also, if you are testing in FPS mode, the boat will appear transparent due to the fact that you put it inside the character. Trying zooming out and looking for the boat.

function unanchor(a)
    for _,Part in pairs(Boat:GetChildren()) do
        if Part:IsA("BasePart") then --If the object is a Part, Wedge, CornerWedge, or Union then...
            Part.Anchored = false
        end
        unanchor(Part) --Check inside each model and part for any parts.
    end
end

game.Players.PlayerAdded:connect(function(plr)
        plr.CharacterAdded:connect(function(char)
        local tors = char:WaitForChild('Torso') --tors is the character's Torso
        local Boat = workspace.Boat:Clone() --Define backpack as a part
        unanchor(Boat)
        local weld = Instance.new('Weld',tors) --Create a new weld object inside tors
        weld.Part0 = tors --A weld needs 2 parts to funciton, this is one of them
        weld.Part1 = Boat.Part --This is the other one
        weld.C0 = CFrame.new(0,0,0)
        Boat.Parent = char --Parent it to the character
    end)
end)

Ad

Answer this question