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: Small question about CFrame

Previous Thread :: Next Thread 
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
05 May 2014 10:07 PM
Just slide.
Report Abuse
golfercab is not online. 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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
05 May 2014 10:15 PM
Wait, but wouldn't you have to GetChildren of the model or something like that?
Report Abuse
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
Paramedic4 is not online. Paramedic4
Joined: 23 Jan 2011
Total Posts: 5934
05 May 2014 10:23 PM
I see, looks quite complex. Thank you!
Report Abuse
golfercab is not online. 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
xXxMoNkEyMaNxXx is not online. xXxMoNkEyMaNxXx
Joined: 03 Oct 2008
Total Posts: 3120
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
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