# Math help for my rock effect

Im creating a rock smash effect (and please note that I know how to do this, i just have a very confusing error that no one seems to be able to fix). Here is my current code, or a chunk of it –

``````local function getEquation(r, a, x,y)
local x,y = r*math.sin(a) ,r*math.cos(a)
return {x,y}
end
local function createCircle(originPart, partSpacing, radius, partParent)

for count = 0,360,partSpacing do

local pa = Instance.new("Part", partParent)
pa.Anchored, pa.CanCollide = true, false

local x,z = tbl, tbl
local px,py,pz = p.CFrame.X,p.CFrame.Y,p.CFrame.Z

pa.CFrame = CFrame.new(px+x, py, pz+z)
transformation(pa, partParent, originPart)

end

end
``````

This seems to work normally, but if I fire the function with, say, partSpacing=72 and radius=15 then it would look like this – https://cdn.discordapp.com/attachments/813561151769542696/996941672652996740/unknown.png

if anyone could help, I would really appreciate it!

The primary issue I see is that the for loop operates with an integer number of degrees while the math library trig functions use radians. A quick fix would be

``````getEquation(radius, math.rad(count))
``````

I don’t think that would explain the weird pattern that was linked though.

Edit: actually, after, closer inspection, I assume those rings are the parts and the issue is the inconsistent spacing, which would be explained by this issue. In the future, a screenshot of what this produces would be more helpful.

2 Likes

thanks for the help - I never got to trying your solution because someone in HiddenDevs helped me fix it, but thanks for helping anyways

thats usually what happens, Ill make a devforum post then someone helps me somewhere else soon after.