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 » Scripting Helpers
Home Search
 

Re: Rotating an object on an axis

Previous Thread :: Next Thread 
Macelarius is not online. Macelarius
Joined: 18 Sep 2012
Total Posts: 104
05 Nov 2014 06:52 PM
Hello, can someone please tell me what is wrong with the following code? I am trying to make the brick 'gun' (which is welded to another brick) rotate 45 degrees on the y axis without moving the other brick.
--Begin code

function Weld(p1,p2)
local weld = Instance.new("Weld")
weld.Part0 = p1
weld.Part1 = p2
weld.C0 = p1.CFrame:inverse()
weld.C1 = p2.CFrame:inverse()
weld.Parent = p1
return weld
end

function rotateDegrees(part,degrees,weld)
weld.C1 = weld.C1 * CFrame.Angles(0,degrees * math.pi/180,0)
end

local w = Weld(gun,ship.mainpart)
rotateDegrees(gun,45,w)
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
05 Nov 2014 07:18 PM
I'm not certain, but I think 'gun' needs to be Part1 instead of Part0 for that.
I am probably wrong though. I just thought Part0 was the anchor, and if you rotate the weld, you rotate Part1.
Report Abuse
Macelarius is not online. Macelarius
Joined: 18 Sep 2012
Total Posts: 104
05 Nov 2014 08:02 PM
Thats definitely not it. Any other ideas?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
05 Nov 2014 08:05 PM
Maybe you should give up and become a poet or playwright.

Seriously though, I'm out of all other ideas.
Report Abuse
anaIyze is not online. anaIyze
Joined: 29 May 2014
Total Posts: 2048
05 Nov 2014 08:17 PM
function rotDeg(p,deg)
p.Weld.C0=p.Weld.C0*CFrame.Angles(0,math.pi/180*deg,0);
end;
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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