This is what I get right now, unintentional degree and tooth amount for the big gear:
as you can see the tooth amount is the same which is supposed to depend on the gears size. The small gear is what I want the gaps to be like, and the big gear is not!!
What I’m asking:
How do I get the amount of teeth I need to create?
How do I get the degree I need to spread the teeth across the circles perimeter?
This is more of how it should be:
NOT MEASURED, just rotated the parts while running the game to give more understanding to my problem
Script inside the cogs model:
--// Variables
local Parent = script.Parent
--// Functions
local function Update()
local function Createpart()
local part = game:GetService("ReplicatedStorage").Tooth:Clone()
part.Anchored = true
part.Size = Vector3.new(.5,1,1)
part.Parent = Parent
return part
end
local Origin = Parent.Base.Position
local StartPart = nil
local CurrentParts = 0
local Degree = 30
local Done = false
repeat
task.wait()
local Part = Createpart()
Part.Position = Origin + Vector3.new(math.cos(math.rad(CurrentParts) * Degree) * Parent.Base.Size.Y/2,0,math.sin(math.rad(CurrentParts) * Degree) * Parent.Base.Size.Y/2)
Part.CFrame = CFrame.lookAt(Part.Position,Parent.Base.Position)
if not StartPart then
StartPart = Part
end
if CurrentParts>1 then
for _,v in workspace:GetPartsInPart(Part) do
if v == StartPart then
Done = true
Part:Destroy()
end
end
end
CurrentParts+=1
until Done
end
--// Script
Update()
I got ratio between gear base size Y(12) divided by normal gear base size Y (4) and for degree did 30/Ratio
new scr
--// Variables
local Parent = script.Parent
local HoleSize = Parent:WaitForChild("HoleSize")
--// Functions
local function Update()
local w = script.Weld:Clone()
w.Part0 = Parent:WaitForChild("Base")
local c = Parent:WaitForChild("Base"):Clone()
c.Size = Vector3.new(Parent.Base.Size.X+1,HoleSize.Value,HoleSize.Value)
c.Massless = true
c.CanCollide = false
c.CanQuery = false
c.CanTouch = false
c.Parent = Parent
w.Part1 = c
local sub = Parent.Base:SubtractAsync({c},Enum.CollisionFidelity.PreciseConvexDecomposition,Enum.RenderFidelity.Precise)
sub.CFrame = Parent.Base.CFrame
sub.Name = "Base"
c:Destroy()
Parent.Base:Destroy()
sub.Parent = script.Parent
local function Createpart()
local part = game:GetService("ReplicatedStorage").Tooth:Clone()
part.Anchored = true
part.Size = Vector3.new(.5,1,1)
part.Parent = Parent
return part
end
local Ratio = Parent.Base.Size.Y/4
local Origin = Parent.Base.Position
local StartPart = nil
local CurrentParts = 0
local Degree = 30/Ratio
print("Ratio : "..Ratio)
local Done = false
repeat
task.wait()
local Part = Createpart()
Part.Position = Origin + Vector3.new(math.cos(math.rad(CurrentParts) * Degree) * Parent.Base.Size.Y/2,0,math.sin(math.rad(CurrentParts) * Degree) * Parent.Base.Size.Y/2)
Part.CFrame = CFrame.lookAt(Part.Position,Parent.Base.Position)
if not StartPart then
StartPart = Part
end
if CurrentParts>1 then
for _,v in workspace:GetPartsInPart(Part) do
if v == StartPart then
Done = true
Part:Destroy()
end
end
end
CurrentParts+=1
until Done
end
--// Script
Update()
HoleSize:GetPropertyChangedSignal("Value"):Connect(function()
Update()
end)