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 CFrame models with scripting?

Previous Thread :: Next Thread 
cyclone3260 is not online. cyclone3260
Joined: 23 Aug 2010
Total Posts: 1038
27 Sep 2012 02:03 PM
I've tried

game.Workspace.Model.CFrame=CFrame.new(0,0,0)

The model wouldn't budge..

Most likely it has something to do with :GetChildren()..


Also if you could leave a link to were I can learn more about this, that would be nice.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
27 Sep 2012 02:06 PM
There is no CFrame property for a model, so yeah, you would have to loop through the children and CFrame them, or just CFrame one part in the model, and make welds between the rest.
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
27 Sep 2012 02:07 PM
If you just want to move a model though, use game.Workspace.Model:MoveTo(Vector3)
Report Abuse
veerstrong is not online. veerstrong
Joined: 23 Jun 2009
Total Posts: 2450
27 Sep 2012 02:29 PM
Actualy, you can move a model through CFrame in a very easy way

for _,v in pairs(game.Workspace.ModelHere:GetChildren()) do
v.CFrame=CFrame.new(0,0,0)
end
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
27 Sep 2012 02:46 PM
Neither of urs works but this does:

game.Workspace.Model:MoveTo(Vector3.new(0,0,0))---Change model to the model's name.

No problem.
Report Abuse
cyclone3260 is not online. cyclone3260
Joined: 23 Aug 2010
Total Posts: 1038
27 Sep 2012 02:55 PM
To WATCH it move there, how do I use?:


for i = 0, 100 do

Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
27 Sep 2012 02:56 PM
You need to move each part relative (according to) another position. That way they all move/rotate in the same direction.

function ModelCFrame(Model, NewCFrame)
Model:MoveTo(NewCFrame.p)
local Origins = {}
for i,v in pairs( Model:GetChildren() ) do
if v:IsA("BasePart") then
Origins[v] = Model:GetModelCFrame():toObjectSpace(v.CFrame)
end
end
for i,v in pairs( Origins ) do
i.CFrame = NewCFrame:toWorldSpace(v)
end
end

ModelCFrame(Workspace.Model, CFrame.Angles(1,0,1))
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
27 Sep 2012 02:57 PM
Consists of using magnitude and some complex math.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
27 Sep 2012 02:58 PM
for i = 0,10, 0.1 do--Change the 10 to how far u want to move it
game.Workspace.Model:MoveTo(Vector3.new(0,i,0))--When the i is in the middle it will watch-move up, to change it, remove the i, replace i with 0, and place i in another vector.
end

Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
27 Sep 2012 02:59 PM
targetPos = ?
movingPart = ? (or model/what ever)
magnitude = (movingPart.Position - targetPos.Position).magnitude

for i = 1, magnitude do

movingPart:MoveTo(movingPart.Pos + (movingPart.Position - targetPos.Position).unit)

end
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
27 Sep 2012 03:00 PM
@Fedora, you're so off.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
27 Sep 2012 03:00 PM
MrNicNac, that rlly wasnt neccasary, its so long and mine works...why so long?
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
27 Sep 2012 03:01 PM
Im so on.
Report Abuse
cyclone3260 is not online. cyclone3260
Joined: 23 Aug 2010
Total Posts: 1038
27 Sep 2012 03:06 PM
@Fedora, I just finish trying yours, it didn't work.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
27 Sep 2012 03:30 PM
Srry, exactly the second script i was unsure off, because i have done that in bricks, and not models, so my work here is finished, anyone else to help him?
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
27 Sep 2012 03:31 PM
Not going to put effort into making a script for cyclone..
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
27 Sep 2012 03:39 PM
"Fedorakid"

Yes it was. Everything in this thread has been the wrong method so far. Mine using relativity to not make those mistakes.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
28 Sep 2012 03:43 AM
I still don see why its so long, i have tested mine and it works perfect..
Report Abuse
eJorge is not online. eJorge
Joined: 09 Jun 2011
Total Posts: 5966
28 Sep 2012 03:43 AM
@Fedorakid
no.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
28 Sep 2012 03:45 AM
@eJorge

Yes.U jus agreed with nicnc cuzz his known as a good scripter, but test it before u post it fails.Idiot.
Report Abuse
eJorge is not online. eJorge
Joined: 09 Jun 2011
Total Posts: 5966
28 Sep 2012 04:24 AM
MrNicNac's function actually CFrames the model, MoveTo won't fusion it with other bricks.

And don't PA. You said I fail and that I'm an idiot.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
28 Sep 2012 04:37 AM
MoveTo Also cframes with the bricks, so go test it before u com with ur smart tounge speaking a lie.
Report Abuse
eJorge is not online. eJorge
Joined: 09 Jun 2011
Total Posts: 5966
28 Sep 2012 04:51 AM
It doesn't.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
28 Sep 2012 05:02 AM
Fine, im gona give u instructions:

Goto an sb, say this (if it works, just wrote it.. or else just make urself cuzz u know what im talking about...)

mod = Instance.new("Model",Workspace)
mod.Name = "Test"

b = Instance.new("Part",mod)
b.Position = Vector3.new(0,10,0)
b.Anchored = true
b.Size = Vector3.new(5,15)



then say this:




game.Workspace.Test:MoveTo(Vector3.new(10,10,10))
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
28 Sep 2012 05:03 AM
And if that doesent work, IM GONA SHOW U MYSELF!CUZZ IT WORKS PERFECTLY FINE!!
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