#Clock with cframe.PivotOffset

1 messages · Page 1 of 1 (latest)

grim matrix
#

trying to make a clock and of course clocks with hands. this is the code for the minute hand however when i run the script, the hand disappears

#

i just realised

#

pivotoffset with that high number

#

im changing it rq

#

to size/2

edgy terrace
#

try to multiply the old CFrame by the

CFrame.fromEulerAnglesXYZ(...)

I think your setting the position to 0,0,0

grim matrix
#

ok i'll try that next if my change didnt work

#

ok didnt work

edgy terrace
#

check the position of your hand in the explorer

grim matrix
#

ok wait

#

your solution worked but the pivot is weird

edgy terrace
#

I think if you dont multiply it sets the position to 0,0,0 but idk I had a similar issue

edgy terrace
#

doesnt that like not exist

grim matrix
#

my game operates in rounds

#

rather than having a remoteevent / bindable event to communicate which maps is getting switched when i just made an inst value

edgy terrace
#

alr lets just concentrate on the CFrame stuff

grim matrix
#

mhm

edgy terrace
#

is it a model?

grim matrix
#

no

#

its a union

edgy terrace
#

PivotOffset only exist for models

grim matrix
#

oh

#

should i just make the union to a model

edgy terrace
#
part.CFrame = CFrame.new(239.53, 333.653, 182.77)
#

replace it with this

grim matrix
#

what

#

doesnt that just move the hand

edgy terrace
#

uhh

#
local function createHand(length, width, yOffset)
    local part = Instance.new("Part")
    part.Size = Vector3.new(width, 0.1, length)
    part.Material = Enum.Material.Neon
    part.PivotOffset = CFrame.new(0, -(yOffset + 0.1), length / 2)
    part.Anchored = true
    part.Parent = workspace
    return part
end

local function positionHand(hand, fraction)
    hand:PivotTo(CFrame.fromEulerAnglesXYZ(0, -fraction * 2 * math.pi, 0))
end

-- Create dial
for i = 0, 11 do
    local dialPart = Instance.new("Part")
    dialPart.Size = Vector3.new(0.2, 0.2, 1)
    dialPart.TopSurface = Enum.SurfaceType.Smooth
    if i == 0 then
        dialPart.Size = Vector3.new(0.2, 0.2, 2)
        dialPart.Color = Color3.new(1, 0, 0)
    end
    dialPart.PivotOffset = CFrame.new(0, -0.1, 10.5)
    dialPart.Anchored = true
    dialPart:PivotTo(CFrame.fromEulerAnglesXYZ(0, (i / 12) * 2 * math.pi, 0))
    dialPart.Parent = workspace
end

-- Create hands
local hourHand = createHand(7, 1, 0)
local minuteHand = createHand(10, 0.6, 0.1)
local secondHand = createHand(11, 0.2, 0.2)

-- Run clock
while true do
    local components = os.date("*t")
    positionHand(hourHand, (components.hour + components.min / 60) / 12)
    positionHand(minuteHand, (components.min + components.sec / 60) / 60)
    positionHand(secondHand, components.sec / 60)
    task.wait()
end
#

maybe this helps

#

the documentation creates a clock aswell

grim matrix
#

yeah but imma be real i cant understand it

#

i already did my fair share of trying to understand it from the docs

edgy terrace
#

I dont rlly understand pivotoffset rn evilcat

#

what is the diffrence between pivotoffset and just pivotto

#

OHHH

#

I get it

#

so you want to set the pivot from red to yellow

#

right

grim matrix
#

ye

edgy terrace
#

im kinda in a hurry rnevilcat

#

I had to go 3 mins ago

#

look

#

I think yojur problem is

#

that your doing the pivot in the world

#

the part has a pivotoffset of 0,0,0

#

and you can like move it in its own world

grim matrix
edgy terrace
#

yee

#

this is better

#

looks better

edgy terrace
#

alr try to fix this wehn it doesnt work im back home in like 30mins and ima help you

#

figure it out

#

gl

edgy terrace
#

does it work

leaden plover
#

Not the whole value

grim matrix
#

ykw i think i'll just use welds instead

leaden plover
#

Lazy but respectful 👍