generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Moving a welded vehicle with CFrame

Previous Thread :: Next Thread 
joshuarome is not online. joshuarome
Joined: 29 Aug 2008
Total Posts: 135
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
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
20 Apr 2015 02:59 PM
CFrame.lookVector*.5
Report Abuse
joshuarome is not online. joshuarome
Joined: 29 Aug 2008
Total Posts: 135
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
TheNewChicken is not online. TheNewChicken
Joined: 18 Mar 2015
Total Posts: 1997
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image