|
| 20 Apr 2015 02:48 PM |
Hello, I have recently been creating a random detailed vehicle, after finishing the model I have been in the process of scripting the actual vehicle, I created the weld function to weld the entire vehicle to the base part(engine) and then I plan to use CFrame as my method of moving the vehicle according to the player, but whenever I attempt to move the vehicle using CFrame, it does not work. Currently all I have to move the vehicle is a basic While True Do loop which will not be used as an end-game product just as a temporary test to move the entire tank at one point. Here is my code at this moment of time:
local tank = script.Parent local cf = CFrame.new
function weld(model) model:BreakJoints() local p = tank.Body for _,part in pairs(model:GetChildren()) do if part:IsA("BasePart") then if p then local weld = Instance.new("Weld",p) weld.C0 = p.CFrame:inverse()*part.CFrame weld.Part0 = p weld.Part1 = part end p.Anchored = false end end end weld(tank)
while true do wait() tank.Body.CFrame = tank.Body.CFrame * cf(0,0,1) end
If anyone could give me any suggestions upon how I can move the entire vehicle with CFrame it would be greatly appreciated. Regards, joshuarome. |
|
|
| Report Abuse |
|
| |
|
| 20 Apr 2015 03:22 PM |
| Sorry I also failed to mention that the above while true loop does work but it only moves the main part called body even though everything is welded to it |
|
|
| Report Abuse |
|
|
| 20 Apr 2015 03:46 PM |
What you want to do is GetChildren, then cframe that if its classname is part or seat
God grant me the wisdom to not punch stupid ppl, for I know I will go to prison. |
|
|
| Report Abuse |
|