|
| 28 May 2016 05:17 PM |
| I want to move a whole model how would I do this? |
|
|
| Report Abuse |
|
|
| |
|
|
| 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 |
|
|
|
| 28 May 2016 05:21 PM |
Oh my gosh! I didn't know that was you cntkillme :p
Thanks! |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 28 May 2016 05:45 PM |
| It's just the new cframe you want the model to be at |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|