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 » Scripters
Home Search
 

Re: How do I move a model

Previous Thread :: Next Thread 
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
28 May 2016 05:17 PM
I want to move a whole model how would I do this?
Report Abuse
GetTheJobDone is not online. GetTheJobDone
Joined: 20 Apr 2016
Total Posts: 3008
28 May 2016 05:17 PM
setprimarypartcframe


Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
28 May 2016 05:17 PM
There are a couple of ways, you could call its MoveTo method or SetPrimaryPartCFrame:

http://wiki.roblox.com/index.php?title=API:Class/Model/MoveTo
http://wiki.roblox.com/index.php?title=API:Class/Model/SetPrimaryPartCFrame
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
28 May 2016 05:21 PM
Oh my gosh! I didn't know that was you cntkillme :p

Thanks!
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
28 May 2016 05:33 PM
Kinda confused what to do next, so this is what I have

crateModel [model]
- model
- crate [going to be primary part]


>>
Do I start something like this?
game.Workspace.crateModel.crate:SetPrimaryPartCFrame(CFrame.new())
>>

local start = game.Workspace.crateStart
local stop = game.Workspace.crateFinish
local multiplier = 1

local part = script.Parent
part.Anchored = true
part.CFrame = start.CFrame

while part.Parent ~= nil do
for i = 0, 1, 0.01 do
part.CFrame = CFrame.new( part.Position:Lerp(stop.Position * multiplier, i) )
wait()
end
for i = 0, 1, 0.01 do
part.CFrame = CFrame.new( part.Position:Lerp(start.Position * multiplier, i) )
wait()
end
wait()
end
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
28 May 2016 05:36 PM
Yeah it'd be Model:SetPrimaryPartCFrame(cframehere)

Although your code underneath is wrong, specifically the Lerping part.
Doing "part.CFrame = CFrame.new( part.Position:Lerp(stop.Position * multiplier, i))" will make it off because it's going to be lerping from the new position instead of the starting position.

local start = part.CFrame.Position
for a = 0, 100, 1 do
part.CFrame = CFrame.new(start:Lerp(stop.Position * multiplier, a/100))
wait()
end
Report Abuse
RealBeta is online. RealBeta
Joined: 23 Jun 2013
Total Posts: 440
28 May 2016 05:39 PM
You could set the position by using "Location" too.


#DevelopersNeverSleep
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
28 May 2016 05:44 PM
On your last post what is cframehere? Is that like the current position you want it to be?


--------------------
script.Parent:SetPrimaryPartCFrame(script.Parent.crate.CFrame)


local start = game.Workspace.crateStart
local stop = game.Workspace.crateFinish
local multiplier = 1

local part = script.Parent
part.Anchored = true
part.CFrame = start.CFrame

while part.Parent ~= nil do
local start = part.CFrame.Position
for a = 0, 100, 1 do
part.CFrame = CFrame.new(start:Lerp(stop.Position * multiplier, a/100))
wait()
end

wait()
end
Report Abuse
RealBeta is online. RealBeta
Joined: 23 Jun 2013
Total Posts: 440
28 May 2016 05:44 PM
Read this line and tell me what you think.

while part.Parent ~= nil do
local start = part.CFrame.Position


#DevelopersNeverSleep
Report Abuse
Flux_Capacitor is not online. Flux_Capacitor
Joined: 07 Apr 2008
Total Posts: 45720
28 May 2016 05:45 PM
It's just the new cframe you want the model to be at
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
28 May 2016 05:49 PM
script.Parent:SetPrimaryPartCFrame()
> so it doesnt move anywhere yet just sets primary part

part.CFrame = start.CFrame
> then moves to start location
Report Abuse
RealBeta is online. RealBeta
Joined: 23 Jun 2013
Total Posts: 440
28 May 2016 05:51 PM
Yes, it's setting the coordinates, then it moves out with the script by setting the CFrame and starting the location of where it should change to.


#DevelopersNeverSleep
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
28 May 2016 05:53 PM
So shouldn't this script be working then? I don't see how it's not working.

script.Parent:SetPrimaryPartCFrame(script.Parent.crate.CFrame)


local start = game.Workspace.crateStart
local stop = game.Workspace.crateFinish
local multiplier = 1

local part = script.Parent
part.Anchored = true
part.CFrame = start.CFrame

while part.Parent ~= nil do
local start = part.CFrame.Position
for a = 0, 100, 1 do
part.CFrame = CFrame.new(start:Lerp(stop.Position * multiplier, a/100))
wait()
end

wait()
end
Report Abuse
RealBeta is online. RealBeta
Joined: 23 Jun 2013
Total Posts: 440
28 May 2016 06:01 PM
It should work. Did you do something wrong? Are you defining to add a new part when the script is being executed?


#DevelopersNeverSleep
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
28 May 2016 06:09 PM
Model:SetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.

oo error

Also why would I need to add a new part?
Report Abuse
RealBeta is online. RealBeta
Joined: 23 Jun 2013
Total Posts: 440
28 May 2016 06:11 PM
If you weren't to add a part you could add the part by script so it's more organized.


#DevelopersNeverSleep
Report Abuse
buildmodel is not online. buildmodel
Joined: 17 Jul 2012
Total Posts: 3778
28 May 2016 06:23 PM
Still nothing is happening


script.Parent.PrimaryPart = script.Parent.crate
script.Parent:SetPrimaryPartCFrame()


local start = game.Workspace.crateStart
local stop = game.Workspace.crateFinish
local multiplier = 1

local part = script.Parent
part.Anchored = true
part.CFrame = start.CFrame

while part.Parent ~= nil do
local start = part.CFrame.Position
for a = 0, 100, 1 do
part.CFrame = CFrame.new(start:Lerp(stop.Position * multiplier, a/100))
wait()
end

wait()
end
Report Abuse
RealBeta is online. RealBeta
Joined: 23 Jun 2013
Total Posts: 440
28 May 2016 06:25 PM
You did everything right of what we told you and you fixed the error, I don't know what seems to be the problem.


#DevelopersNeverSleep
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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