Setting a part's CFrame is causing it to go trillions of studs deep into the void

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like my part not to be trillions of studs deep in the void please

  2. What is the issue? Include screenshots / videos if possible!
    I was wondering why my function that spawns something wasn’t spawning, i put a temporary part there and it’s being sent millions of miles into the void

This is the code. I don’t see a problem with the CFrame,
“breakPos” prints where it’s actually supposed to be, so it must be something with this CFrame

local a = Instance.new("Part")
a.Anchored = true
a.CFrame = CFrame.new(breakPos) * CFrame.new(0, 4, 0) * CFrame.Angles(0, math.rad(360 / #stones) * count, 0)
a.Size = Vector3.new(1, 1, 1)
a.Name = "AA"
a.Parent = game.Workspace
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve googled the number, as it was so exact and apparently it’s the maximum allowable size for a floating point value, this info didn’t do much help to me though

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Screenshot of the position
image

EDIT:
After rewriting it, changing absolutely nothing, the part is now exactly -1,000,000 studs in the void, it’s closer right? v

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

having this problem as well. Apparently it only happens when I add a rotation to the cframe or change the orientation of a part to the direction of my shot

What happens if you do each step individually?

a.CFrame = CFrame.new(breakPos)
print(a.Position)
a.CFrame = a.CFrame * CFrame.new(0, 4, 0)
print(a.Position)
a.CFrame = a.CFrame * CFrame.Angles(0, math.rad(360 / #stones) * count, 0)
print(a.Position)

Maybe you can see which one is throwing it way out there. You might also want to make sure #stones and count are what you expect them to be.

Chain of events:

  1. 360 / #stones will return inf if there are no stones.
  2. math.rad will return inf if it is given inf.
  3. The CFrame.Angles constructor will return a CFrame with NaN values if it is given inf.
  4. CFrames with NaN values have crazy numbers that nobody sane can work with.

Figure out what you’d like math.rad to be if there are no stones, and use that when #stones is 0 instead of that radian conversion calculation. But still do that conversion if there are stones.