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: CFrame.new

Previous Thread :: Next Thread 
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 02:40 PM
I don't get it. I looked at the wiki, it doesn't make sense, can someone make it simpler? I'm a newbie scripter, I need some help with Lua :\
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 02:40 PM
I do know alot of basic lua, though.
Report Abuse
thecaptain97 is not online. thecaptain97
Joined: 17 Jun 2010
Total Posts: 4987
03 Aug 2012 02:41 PM
workspace.Part5.CFrame = CFrame.new(90,56,70)


the (90,56,70) Part is the Coords.
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 02:42 PM
That makes sense, but the CFrame.new(0,10,0) * CFrame.Angles(0,math.pi,0) isn't clear to me e.e
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 02:43 PM
Wait, it's starting to make more sense now...
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
03 Aug 2012 02:48 PM
path.pi = 180º
math.pi/2 = 90º
math.pi/4 = 45º

CFrame.new(double x, double y, double z) * CFrame.Angles(Bank, spin, tilt)

Bank spin and tilt all have to follow the math.pi principle.

so, if you wanted to make a rotating part,

while wait() do
script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0, math.pi/12, 0)
end

Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
03 Aug 2012 02:50 PM
You can also optionally use math.rad(angle) if you want to rotate a spesific angle.

math.rad(45) = math.pi/4
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:00 PM
math.pi/2 (A quarter turn, or 90 degrees)
math.pi (A half turn, or 180 degrees)
math.pi*2 (A full turn, or 360 degrees)
math.pi + math.pi/2 (Three-quarters turn, or 270 degrees)
^copied and pasted from the wiki^

I know that, how would I make it so that it would create a part and rotate it and move it to someones head?

p = Instance.new("Part",game.Workspace.Player)
p.Name = "hat"
p.CFrame = CFrame.new(p.Position) * CFrame.Angles(0,math.pi/4,0)

Would that work?
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
03 Aug 2012 03:01 PM
No, you need a special hat class called "Accoutrement", which is the user created version of hats.
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:03 PM
Wait, it wouldn't.
player = game.Workspace.Player

p = Instance.new("Part",player)
p.Name = "hat"
head = player["Head"]
if head then
p.Position = head.Position
p.CFrame = CFrame.new(p.Position) * CFrame.Angles(0,math.pi/4,0)
end

^That would work, wouldn't it?^
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
03 Aug 2012 03:04 PM
No, because the block would bounce off of the players head after positionning itself.
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:05 PM
We need to weld it then.
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
03 Aug 2012 03:07 PM
or anchor it, which will be funny because you couldn't move.
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:10 PM
    player = game.Workspace.Player
    p = Instance.new("Part",player)
    p.Name = "hat"
    head = player["Head"]
    if head then
    p.Position = head.Position
    p.CFrame = CFrame.new(p.Position.X,p.Position.Y+5,p.Position.Z) * CFrame.Angles(0,math.pi/4,0)
    p.Anchored = true
    end

lol
    
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:11 PM
I said p.Position.Y+5, so that it would be anchored on the persons head, not in.
Report Abuse
Xnite515 is not online. Xnite515
Joined: 18 Feb 2011
Total Posts: 22763
03 Aug 2012 03:12 PM
a = Instance.new("Weld") --is there any such thing as headweld
a.Parent = p --I think


--i thibk
Report Abuse
AdvorsusDuo is not online. AdvorsusDuo
Joined: 17 May 2012
Total Posts: 5265
03 Aug 2012 03:12 PM
Would not work. You'd still need a Weld to connect the anchored brick to the head.

The character would be immediately pushed out of the brick unless welded.

-Nick
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
03 Aug 2012 03:15 PM
local name = "" -- insert name here

local p = Instance.new("Part", workspace)
p.CanCollide = false
local w = Instance.new("Weld", p)
w.Part0 = p
w.Part1 = workspace[name].Head

There you go
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:15 PM
function Weld(Part0, Part1)
w = Instance.new("Weld")
w.Parent = Part0
w.Part0 = Part0
w.Part1 = Part1
end

player = game.Workspace.Player
p = Instance.new("Part",player)
p.Name = "hat"
head = player["Head"]
if head then
p.Position = head.Position
p.CFrame = CFrame.new(p.Position.X,p.Position.Y+2.5,p.Position.Z) * CFrame.Angles(0,math.pi/4,0)
p.Anchored = false
Weld(p, head)
end


^That should work^
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:24 PM
It worked, it just didn't rotate?
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:31 PM
Hello? -.-


    function Weld(Part0, Part1)
        w = Instance.new("Weld")
        w.Parent = Part0
        w.Part0 = Part0
        w.Part1 = Part1
    end
    
    player = game.Workspace.Player
    p = Instance.new("Part",player)
    p.Name = "hat"
    head = player["Head"]
    if head then
        f = 5
        p.Position = head.Position
        x = p.Position.X
        y = p.Position.Y + 2.5
        z = p.Position.Z
        p.CFrame = CFrame.new(x,y,z) * CFrame.Angles(math.pi/2,math.pi,math.pi + math.pi/2)
        p.Anchored = false
        Weld(p, head)
    end

That's what I have, it works, but it won't rotate, it just covers my head, and it doesn't move ON TOP of my head, just stays there. Can someone help me?
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
03 Aug 2012 03:41 PM
local offsetx, offsety, offsetz = 0, 5, 0
local rotationx, rotationy, rotationz = 0, math.rad(90), 0
local name = "" -- insert name here

local p = Instance.new("Part", workspace)
p.CanCollide = false
local w = Instance.new("Weld", p)
w.Part0 = p
w.C1 = CFrame.new(offsetx, offsety, offsetz) * CFrame.Angles(rotationx, rotationy, rotationz)
w.Part1 = workspace[name].Head
Report Abuse
filj is not online. filj
Joined: 24 Jul 2012
Total Posts: 72
03 Aug 2012 03:48 PM
When I use that, it makes a floating brick above my head that's really high, and it didn't rotate.

Does CFrame.Angles even work?
btw, what's C1?
Report Abuse
SpeedySeat is online. SpeedySeat
Joined: 06 Jul 2011
Total Posts: 3048
03 Aug 2012 04:18 PM
I made it so it goes really high above your head.

Also the block is rotated 90 degrees, it is inverted.
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