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 expected, got vector3

Previous Thread :: Next Thread 
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:24 AM
function Fix(Part)
pos=Vector3.new(
(math.floor(Part.Position.X*RoundBy + 0.5))/RoundBy,
(math.floor(Part.Position.Y*RoundBy + 0.5))/RoundBy,
(math.floor(Part.Position.Z*RoundBy + 0.5))/RoundBy
)
rot=Vector3.new(
(math.floor(Part.Rotation.X*RoundDegree + 0.5))/RoundDegree,
(math.floor(Part.Rotation.Y*RoundDegree + 0.5))/RoundDegree,
(math.floor(Part.Rotation.Z*RoundDegree + 0.5))/RoundDegree
)
Part.CFrame=CFrame.new(pos) * rot
end

Workspace.script:11: bad argument #3 to 'CFrame' (CFrame expected, got Vector3)

what?
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:25 AM
forgot these

local RoundBy=10
local RoundDegree=15
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
29 Jan 2017 07:25 AM
You can't multiply a CFrame with a vector3, you can multiply it with a CFrame.
Report Abuse
OzzyFin is not online. OzzyFin
Joined: 07 Jun 2011
Total Posts: 3600
29 Jan 2017 07:26 AM
nvm you can totally multiply it with a v3 im stupid
what is line 11
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:28 AM
line 11 = Part.CFrame=CFrame.new(pos) * rot
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:31 AM
I tried Part.CFrame=CFrame.new(pos) * CFrame.Angles(rot)
but that got me
bad argument #3 to 'Angles' (number expected, got no value)
14:30:44.846 - Stack Begin
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
29 Jan 2017 07:33 AM
for rot

instead of Vector3.new

put

CFrame.Angles

might want to convert to radians first though


Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:37 AM
^^
read my previous message
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
29 Jan 2017 07:39 AM
nonono

this line

rot=CFrame.Angles(
(math.floor(Part.Rotation.X*RoundDegree + 0.5))/RoundDegree,
(math.floor(Part.Rotation.Y*RoundDegree + 0.5))/RoundDegree,
(math.floor(Part.Rotation.Z*RoundDegree + 0.5))/RoundDegree
)


Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:40 AM
local RoundBy=10
local RoundDegree=15--round to nearest x degrees
local r = math.rad


function Fix(Part)
pos=Vector3.new(
(math.floor(Part.Position.X*RoundBy + 0.5))/RoundBy,
(math.floor(Part.Position.Y*RoundBy + 0.5))/RoundBy,
(math.floor(Part.Position.Z*RoundBy + 0.5))/RoundBy
)
rot=Vector3.new(
(math.floor(Part.Rotation.X*RoundDegree + 0.5))/RoundDegree,
(math.floor(Part.Rotation.Y*RoundDegree + 0.5))/RoundDegree,
(math.floor(Part.Rotation.Z*RoundDegree + 0.5))/RoundDegree
)
Part.CFrame=CFrame.new(pos) * CFrame.Angles(r(rot.X),r(rot.Y),r(rot.Z))
end


This works technically, but the position of the parts are all weird and warped.
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
29 Jan 2017 07:42 AM
function Fix(Part)
local r = math.rad

pos=Vector3.new(
(math.floor(Part.Position.X*RoundBy + 0.5))/RoundBy,
(math.floor(Part.Position.Y*RoundBy + 0.5))/RoundBy,
(math.floor(Part.Position.Z*RoundBy + 0.5))/RoundBy
)
rot=CFrame.Angles(
(r(math.floor(Part.Rotation.X*RoundDegree + 0.5))/RoundDegree),
(r(math.floor(Part.Rotation.Y*RoundDegree + 0.5))/RoundDegree),
(r(math.floor(Part.Rotation.Z*RoundDegree + 0.5))/RoundDegree)
)
Part.CFrame=CFrame.new(pos) * rot
end

copy that exactly?


Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:44 AM
It's not the rotation. The position is weird though. I am applying CFrame to all kinds of parts, both anchored and unanchored, and welded? Maybe the welds is doing something weird.
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:45 AM
For clarification, RoundBy, rounds to the nearest RoundBy^-1 position on the axis
Report Abuse
haskjdfsask is not online. haskjdfsask
Joined: 08 Jun 2014
Total Posts: 810
29 Jan 2017 07:49 AM
I fixed it.
It's a script that corrects the brickshift glitch btw, I'm sure you know what it is (or google it)

Script:


local RoundBy=10--rounds to the nearest RoundBy^-1 position on the axis
local RoundDegree=15--round to nearest x degrees
local r = math.rad

function Fix(Part)
pos=Vector3.new(
(math.floor(Part.Position.X*RoundBy + 0.5))/RoundBy,
(math.floor(Part.Position.Y*RoundBy + 0.5))/RoundBy,
(math.floor(Part.Position.Z*RoundBy + 0.5))/RoundBy
)
rot=Vector3.new(
(math.floor(Part.Rotation.X*RoundDegree + 0.5))/RoundDegree,
(math.floor(Part.Rotation.Y*RoundDegree + 0.5))/RoundDegree,
(math.floor(Part.Rotation.Z*RoundDegree + 0.5))/RoundDegree
)
Part:BreakJoints()
Part.CFrame=CFrame.new(pos) * CFrame.Angles(r(rot.X),r(rot.Y),r(rot.Z))
Part:MakeJoints()
end

function Find(Part)
Inside = Part:GetChildren()
if Part.ClassName=="Seat" or Part.ClassName=="Union" or Part.ClassName=="VehicleSeat" or Part.ClassName=="Part" or Part.ClassName=="MeshPart" then
Fix(Part)
for _, InsidePart in pairs (Inside) do
Find(InsidePart)
end
end
end

function Correct(Subject)
for _, Obj in pairs(Subject:GetChildren()) do
Find(Obj)
end
end

Correct(workspace["Model name here"])
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