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 can i CFRAME a model position ??

Previous Thread :: Next Thread 
temprezors is not online. temprezors
Joined: 11 Sep 2013
Total Posts: 226
15 Jun 2014 05:26 AM
as for the tittel said

also like :

model = script.Parent
modelposition = ???? idk

bla bla bla
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
15 Jun 2014 05:28 AM
model:MoveTo()

Either that or you make a loop that moves every part of the model to a new position while keeping their relative positions the same.
Report Abuse
temprezors is not online. temprezors
Joined: 11 Sep 2013
Total Posts: 226
15 Jun 2014 05:31 AM
oh boy :(
thanks anyway
Report Abuse
temprezors is not online. temprezors
Joined: 11 Sep 2013
Total Posts: 226
15 Jun 2014 05:32 AM
also how can i move him from his original position to his original position but littel higher please give an example too
Report Abuse
temprezors is not online. temprezors
Joined: 11 Sep 2013
Total Posts: 226
15 Jun 2014 05:35 AM
nvm i got it
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
15 Jun 2014 05:50 AM
I'm writing this off the top of my head:

function CFrameModel(model,position,angle)
if not model:IsA("Model") then return end

local parts = {}

local function scan(part)
local children = part:GetChildren()

if part:IsA("BasePart") then
table.insert(parts,part)
end

if #children > 0 then
for _, v in pairs(children) do
scan(v)
end
end
end

scan(model)

local offset
local angles
local new_angles
local centre = model:GetModelCFrame().p

for i,v in pairs(parts) do

offset = v.Position - centre
angles = v.CFrame - v.Position
new_angles = angles * angle
v.CFrame = CFrame.new(position+offset) * new_angles
end

end

Example usage:

CFrameModel(Workspace.Model,Vector3.new(0,10,0),CFrame.Angles(0,math.pi/2,0))

The advantage over the MoveTo method obviously being you can rotate using this and it won't move the parts if they intersect(if they're anchored)
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
15 Jun 2014 06:07 AM
For the distance thingy

player = game.Players.LocalPlayer
character = player.Character

--When E is pressed

if mouse.Target == nil then return end

local distance = (character:GetModelCFRame().p - mouse.Target.Position).magnitude

if distance > 20 then return end
Report Abuse
temprezors is not online. temprezors
Joined: 11 Sep 2013
Total Posts: 226
15 Jun 2014 06:12 AM
Script :


plr = game.Players.LocalPlayer
epic = plr:GetMouse()


epic.KeyDown:connect(function(key)
ypcall(function()
if key:lower() == "e" then
game.Workspace.Cell.Script.Disabled = false -- this will make the cell get up then get down

end
end)
end)


while wait() do
ypcall(function()
end)
end
Report Abuse
temprezors is not online. temprezors
Joined: 11 Sep 2013
Total Posts: 226
15 Jun 2014 06:15 AM
also here is the Disabled script :


game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , 1 , 0))
wait(7)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))
wait(.4)
game.Workspace.Cell:TranslateBy(Vector3.new(0 , -1 , 0))

script.Disabled = true
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
15 Jun 2014 06:20 AM
try that

plr = game.Players.LocalPlayer
epic = plr:GetMouse()
cell = game.Workspace.Cell


epic.KeyDown:connect(function(key)
ypcall(function()
dist = (plr.Torso.Position - mouse.Target.Position).Magnitude
if key:lower() == "e" and epic.Target:IsDescendantOf(cell) and dist < 20 then
cell.Script.Disabled = false -- this will make the cell get up then get down
end
end)
end)
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