|
| 05 May 2014 10:01 PM |
| So if I wanted to make a model move with CFrame how would the script look like? |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 10:02 PM |
| By "move" do you mean slide, or do you mean turn, or do you mean something else entirely? |
|
|
| Report Abuse |
|
|
| |
|
golfercab
|
  |
| Joined: 26 Sep 2011 |
| Total Posts: 714 |
|
|
| 05 May 2014 10:11 PM |
see.... that is something that not many people seem to not know about and I don't really know either =P. If you are just positioning something within studio you can use:
for i,t in pairs(game.Selection:Get()) do t. CFrame = t.CFrame + Vector3.new(0,0,0) end
make sure you copy and paste it into the command bar and that you have the parts selected when you use command (can't be grouped)
To have a script move an object while the game is running and with people in it... I'm guessing it would have something to do with selecting the models children? then name.CFrame = CFrame + Vector3.new(#,#,#) ? |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 10:12 PM |
local function SlideTo(part,position,period) local t0=tick() local c0=part.CFrame repeat part.CFrame=c0+(position-c0.p)*(tick()-t0)/period wait() until tick()-t0>period part.CFrame=c0-c0.p+position end
--Slide Part to (20,20,-5) in 5 seconds SlideTo(workspace.Part,Vector3.new(20,20,-5),5) |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 10:15 PM |
| Wait, but wouldn't you have to GetChildren of the model or something like that? |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 10:18 PM |
Oh, a model...
--CFrame a model local function MulCFrame(obj,cf) if obj:IsA'BasePart' then obj.CFrame=cf*obj.CFrame end for _,child in next,obj:GetChildren() do MulCFrame(child,cf) end end local function SetModelCFrame(model,CFrame) MulCFrame(model,CFrame*model:GetModelCFrame():inverse()) end
local function SlideTo(model,position,period) local t0=tick() local c0=model:GetModelCFrame() repeat SetModelCFrame(model,c0+(position-c0.p)*(tick()-t0)/period) wait() until tick()-t0>period SetModelCFrame(model,c0-c0.p+position) end |
|
|
| Report Abuse |
|
|
|
| 05 May 2014 10:23 PM |
| I see, looks quite complex. Thank you! |
|
|
| Report Abuse |
|
|
golfercab
|
  |
| Joined: 26 Sep 2011 |
| Total Posts: 714 |
|
|
| 05 May 2014 11:13 PM |
| How did you learn so much about scripting monkeyman? =o |
|
|
| Report Abuse |
|
|
|
| 06 May 2014 06:20 AM |
I've had a few years of practice, and people tell me that I'm smart. (and I believe them)
modest too.. |
|
|
| Report Abuse |
|
|