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: CFrame help?

Previous Thread :: Next Thread 
StarKeep is not online. StarKeep
Joined: 29 Jun 2016
Total Posts: 92
14 Jan 2017 11:29 PM
--It is saying Vector3 expected, got CFrame. But this must all be a CFrame in order for my script to work. Help?

local HitPoint = CFrame.new(Selected.Main.CFrame + Vector3.new(math.floor(Mouse.Hit.p.x/1 + 0.5)*1, 3.2, math.floor(Mouse.Hit.p.z/1 + 0.5)*1))
Report Abuse
MK_0 is online. MK_0
Joined: 28 Aug 2010
Total Posts: 1651
14 Jan 2017 11:33 PM
CFrame.new(Selected.Main.CFrame.p + Vector3.new(math.floor(Mouse.Hit.p.x/1 + 0.5)), 3.2, math.floor(Mouse.Hit.p.z/1 + 0.5)*1)


Report Abuse
Captain_PeachFuzz is not online. Captain_PeachFuzz
Joined: 08 Apr 2009
Total Posts: 223
14 Jan 2017 11:34 PM
It's because of this: "CFrame.new(Selected.Main.CFrame" You can't define a CFrame with a CFrame in it.

Try this instead:

local HitPoint = Selected.Main.CFrame * CFrame.new(math.floor(Mouse.Hit.p.x/1 + 0.5)*1, 3.2, math.floor(Mouse.Hit.p.z/1 + 0.5)*1)


~Who's awesome? You're awesome!
Report Abuse
MK_0 is online. MK_0
Joined: 28 Aug 2010
Total Posts: 1651
14 Jan 2017 11:36 PM
"You can't define a CFrame with a CFrame in it."

Yes, you can.


Report Abuse
Captain_PeachFuzz is not online. Captain_PeachFuzz
Joined: 08 Apr 2009
Total Posts: 223
14 Jan 2017 11:38 PM
No you can't; CFrame.new(CFrame.new(0,0,0)) returns the same error.


~Who's awesome? You're awesome!
Report Abuse
StarKeep is not online. StarKeep
Joined: 29 Jun 2016
Total Posts: 92
14 Jan 2017 11:38 PM
doesnt work
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
14 Jan 2017 11:38 PM
Adding a CFrame to a Vector3 (which is what the OP did) returns a CFrame and there's no CFrame constructor that does that takes a CFrame because that doesn't make sense.
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
14 Jan 2017 11:39 PM
lol, you're all overcomplicating this:

local HitPoint = Selected.Main.CFrame + Vector3.new(math.floor(Mouse.Hit.p.x/1 + 0.5)*1, 3.2, math.floor(Mouse.Hit.p.z/1 + 0.5)*1)
Report Abuse
MK_0 is online. MK_0
Joined: 28 Aug 2010
Total Posts: 1651
14 Jan 2017 11:39 PM

Um.

print(CFrame.new(CFrame.new(5,5,5).p,1,5))


Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
14 Jan 2017 11:40 PM
What's the point in dividing by 1 then multiplying after rounding, unless that's a placeholder for another number?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
14 Jan 2017 11:40 PM
mk0 CFrame.new(x,y,z).p RETURNS a Vector3
Report Abuse
MK_0 is online. MK_0
Joined: 28 Aug 2010
Total Posts: 1651
14 Jan 2017 11:41 PM
I just testing mine it does work.


Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
14 Jan 2017 11:41 PM
@MK_0 Passing in a CFrame is something entirely different than passing in a vector component of a CFrame.


OP did this

CFrame.new(someCFrame) --// passing in a cframe (doesn't make sense and will error)

That isn't the same as

CFrame.new(someCFrame.p) --// passing in a vector (position)
Report Abuse
Captain_PeachFuzz is not online. Captain_PeachFuzz
Joined: 08 Apr 2009
Total Posts: 223
14 Jan 2017 11:42 PM
CFrame.new(5,5,5).p makes it into a Vector. I kept the CFrame because I assumed he wanted to keep rotation.


~Who's awesome? You're awesome!
Report Abuse
StarKeep is not online. StarKeep
Joined: 29 Jun 2016
Total Posts: 92
14 Jan 2017 11:42 PM
@casual

Unable to cast Vector3 to CoordinateFrame
Report Abuse
MK_0 is online. MK_0
Joined: 28 Aug 2010
Total Posts: 1651
14 Jan 2017 11:44 PM
If he wanted to keep the rotation why not just say so...


Report Abuse
StarKeep is not online. StarKeep
Joined: 29 Jun 2016
Total Posts: 92
14 Jan 2017 11:45 PM
I want to keep the rotation
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
14 Jan 2017 11:46 PM
@OP Context please; I've post a few snippets in this thread so you're going to have to tell me which snippet you're using//what you're doing with it to get said error.


@MK_0 Considering they are trying to make a new by offsetting a different CFrame it should be intuitive that's probably what they're going for (preservation of rotation).
Report Abuse
StarKeep is not online. StarKeep
Joined: 29 Jun 2016
Total Posts: 92
14 Jan 2017 11:48 PM
I am trying to have furniture follow your mouse. I allow you to rotate the furniture with keys, but whenever the Mouse is moved it resets the rotation and makes it 0 degrees.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
14 Jan 2017 11:49 PM
local oldRot = o.CFrame - o.Position
o.CFrmae = CFrame.new(newPos) * oldRot

Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
14 Jan 2017 11:50 PM
Codewise context.

There's several different snippets of code in this thread; to debug your new error we need to know what code you ran that's generating that error
Report Abuse
Captain_PeachFuzz is not online. Captain_PeachFuzz
Joined: 08 Apr 2009
Total Posts: 223
14 Jan 2017 11:52 PM
You can have a variable in the script 'Rotation = 0'

Then when you press a key, it adds 1 or subtracts 1, so rotation goes up/down.
Then when you calculate the position of the furniture, you add the rotation using ' * CFrame.Angles(0,math.rad(Rotation),0)'


~Who's awesome? You're awesome!
Report Abuse
MK_0 is online. MK_0
Joined: 28 Aug 2010
Total Posts: 1651
14 Jan 2017 11:53 PM
local Rotation = Selected.Main.CFrame - Selected.Main.CFrame.p


local Hit = CFrame.new(Selected.Main.CFrame.p + Vector3.new(math.floor(Mouse.Hit.p.x/1 + 0.5)), 3.2, math.floor(Mouse.Hit.p.z/1 + 0.5)*1) * Rotation





Report Abuse
StarKeep is not online. StarKeep
Joined: 29 Jun 2016
Total Posts: 92
15 Jan 2017 12:38 AM
@MK

It works great but it only stays moves on one axis (Ex. Left and right)
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