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: How to rotate the Cframe of a model?

Previous Thread :: Next Thread 
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 04:27 PM
How?
This is how you change the Vector3 posistion but I need to rotate it by the CFrame

script.Parent:MoveTo(Vector3.new(0,0,0))

How do I change the CFrame Rotation?
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
16 Aug 2013 04:28 PM
ask a doctor
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 04:29 PM
That makes no sence.
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
16 Aug 2013 04:30 PM
ok mom ask ur dad
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
16 Aug 2013 04:34 PM
function CFrameModel(model, newcframe)
for i,v in pairs(CFrameModel:GetChildren())do
if v:IsA("BasePart") then
v.CFrame = newcframe:ToWorldSpace(model:GetModelCFrame():ToObjectSpace(v.CFrame))
end
CFrameModel(v, newcframe)
end
end

I think that might work.
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 04:36 PM
Dident do anything, no output.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
16 Aug 2013 04:42 PM
for i,v in pairs(CFrameModel:GetChildren())do


I meant model, not CFrameModel
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 04:42 PM
.. NO one cares?
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 04:53 PM
Why did I say no one cares?
Oh thats right! Wrong post.
SORRY!
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 04:56 PM
Anyway thanks, But I dont know how I can edit it so
while true do
wait(1)
--Code
end

... Not the best scripter in the world.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
16 Aug 2013 05:05 PM
CFrameModel(Workspace.Model, CFrame.new(0, 0, 0))
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 05:06 PM
Thanks.
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 05:12 PM
ARG NOT WORKING.

function CFrameModel(model, newcframe)
for i,v in pairs(model:GetChildren())do
if v:IsA("BasePart") then
v.CFrame = newcframe:ToWorldSpace(model:GetModelCFrame():ToObjectSpace(v.CFrame))
end
CFrameModel(v, newcframe)
end
end
while true do
wait(.1)
CFrameModel(script.Parent, CFrame.new(0, 0, 0))
end
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
16 Aug 2013 05:13 PM
That should just keep the model at CFrame.new(0, 0, 0)
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 05:19 PM
It dident move at all and it errored.. Forgot to tell you the output...
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 05:19 PM
17:19:14.346 - ToWorldSpace is not a valid member
17:19:14.347 - Script "Workspace.Model.Script", Line 4 - global CFrameModel
17:19:14.348 - Script "Workspace.Model.Script", Line 11
17:19:14.348 - stack end


STupid foodcheck.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
16 Aug 2013 05:22 PM
toWorldSpace, toObjectSpace

Change those.
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 05:29 PM
Thank you all the way, but I still dont know how to only change the Rotation of the model not its Position..


This is what I have.
CFrameModel(script.Parent, CFrame.new(0, 0, 0)*CFrame.Angles(0, math.pi,5))



This is what I thought but there was an error.
Workspace.Model.Script:11: bad argument #1 to '?' (CFrame expected, got table)

CFrameModel(script.Parent, CFrame * CFrame.new(0,0,0)*CFrame.Angles(0, math.pi,5))
Report Abuse
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
16 Aug 2013 05:50 PM
lol u still have not found the answer? i have the answer lol 1sec i get it from my game :3
Report Abuse
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
16 Aug 2013 05:54 PM
function TransformModel(objects, center, new, recurse)
for _,object in pairs(objects) do
if object:IsA("Part") then
object.CFrame = new:toWorldSpace(center:toObjectSpace(object.CFrame))
end
if recurse then
TransformModel(object:GetChildren(), center, new, true)
end
end
end

while true do
local center = script.Parent.Parent:GetModelCFrame()
TransformModel(
script.Parent:GetChildren(), -- model you want to rotate lol
center,
center * CFrame.Angles(0,math.rad(1),0), -- how much you want to rotate in
true
)
wait(0.05)
end


lol you only need to edit the 2nd half, for the rotation use math.rad(degrees) i used 1 because i made the wait 0.05, i wanted a smooth spinning motion...

also this is on a while true do loop so u might need to remove that if you dont need it and remove the end at the end lol and the wait(0.05) of course.
Report Abuse
kingmatt2 is not online. kingmatt2
Joined: 20 Aug 2011
Total Posts: 6494
16 Aug 2013 05:55 PM
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!
Report Abuse
PRESTIGIOUSaLEGEND is not online. PRESTIGIOUSaLEGEND
Joined: 16 Apr 2011
Total Posts: 1765
16 Aug 2013 05:58 PM
lol :)
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