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

How do you weld a ship with hundreds of parts together with a script so it can move?

Asked by 10 years ago

I am trying to weld a pirate ship together with code so that it can move through the water. Unfortunately I haven't been able to figure out the right coding. I have tried many different codes but they don't seem to work. Such as: w = Instance.new("Weld") w.Part0 = _____ w.C0 = ____.CFrame:inverse() w.Part1 = script.Parent w.C1 = script.Parent.CFrame:inverse() w.Parent = script.Parent

Just doesn't work


Parts = -- Place where all the blocks are Engine = -- Main block Get = {} for _,v in pairs(Parts:GetChildren()) do if v:IsA("BasePart") then table.insert(Get,v) if v ~= Engine then local Weld = Instance.new("Weld") Weld.Part0 = Engine Weld.Part1 = v Weld.C0 = CFrame.new() Weld.C1 = v.CFrame:inverse() * Engine.CFrame Weld.Parent = Engine end end end wait() for _,v in pairs(Get) do v.Anchored = false end

For this code it says It says Workspace.Deck.Script:3: attempt to index global 'Parts' (a nil value)


local prev

02 for _,v in ipairs(script.Parent:GetChildren()) do

03 if v:IsA("BasePart") then

04 if prev ~= nil then

05 local w = Instance.new("Weld")

06 local a = v.CFrame:inverse()

07 local b = prev.CFrame:inverse()

08 w.Part0 = v

09 w.Part1 = prev

10 w.C0 = a

11 w.C1 = b

12 w.Parent = v

13 v.Anchored = false

14 end

15 prev = v

16 end

17 end

For this code, it doesn't come into any errors but does not work correctly


Please help with code and instructions. The boat needs to be all welded together and unanchored.

0
Code block please. Just select the whole script text and press the Lua icon. Tesouro 407 — 10y

Answer this question