#Tryna make the teeth open and close without other axis' rotating

1 messages · Page 1 of 1 (latest)

fervent cave
#

here is script also yes its ai "local teeth = script.Parent
local top = teeth:WaitForChild("Top")
local topAttachment = top:FindFirstChildOfClass("Attachment")

local hingePos = topAttachment.WorldPosition -- fixed hinge position in world space
local chompSpeed = 2
local chompAngleDegrees = 30

local originalCFrame = top.CFrame

task.spawn(function()
while true do
local t = tick()
local angle = math.sin(t * chompSpeed * math.pi * 2) * math.rad(chompAngleDegrees)

    -- Vector from hinge to part pivot in world space
    local pivotToHinge = top.CFrame.Position - hingePos

    -- Rotate this vector around hinge by angle about Z axis (local to hinge)
    local rotation = CFrame.Angles(0, 0, angle)

    -- New position for part pivot, rotated around hinge
    local newPos = hingePos + (rotation * pivotToHinge)

    -- Calculate new CFrame: rotated by angle around hinge, positioned so hinge stays at hingePos
    local newCFrame = CFrame.new(newPos) * CFrame.Angles(0, 0, angle) * (top.CFrame - top.CFrame.Position)

    top.CFrame = newCFrame

    task.wait(1/60)
end

end)
"

#

currently using hingeconstraints

fervent cave
#

@slim pollen can i get help or naw?

sturdy pivot
sturdy pivot
#

you could also set the top part mass to 0

fervent cave
#

but i need it to chase players

fervent cave
sturdy pivot
slim pollen
fervent cave