Attempt at Working Garage Door

Howdy! I’m currently working on making a functional garage bay door for a fire station, however I cannot seem to make a model pivot to the position it should be in while opened. My attempts so far have been unsuccessful through reference of existing questions similar on the DevForum.

I apologize for what probably is a horrible attempt at scripting :joy:, I really only build however I usually can scrape something functional together, though in this instance I can’t.

My goal is to make the bay door open up in a garage-fashion, however I’m not looking for it to be animated, I just need it to snap open when a button is clicked.

image

local click = script.Parent.ClickDetector

if click.MouseClick == true then
	door:PivotTo(CFrame.new(Vector3.new(-32.35, 15.2, 17.1)))
end```
1 Like

Good attempt so far, try:

local click = script.Parent.ClickDetector
local door = -- Reference to your garage bay door model, you need to define this

click.MouseClick:Connect(function() -- ClickDetector fires an event you can listen to.
    local targetPosition = Vector3.new(-32.35, 15.2, 17.1)
    
    -- Move the door to the target position
    door:SetPrimaryPartCFrame(CFrame.new(targetPosition))
end)

How should I go about rectifying this error that appears in the Output?

Ah, this is my bad.

You need to click on your model, find the ‘PrimaryPart’ property, click the blank value next to it, then select the part you’re basing your position off of. Usually this is the main part in the model. If it’s a garage door, the door itself would be the primary part.

Got it working, just have to fix the orientation. Thank you for your help, it’s much appreciated!

1 Like

Really quickly, how would you go about fixing the orientation? I have the orientations, I just don’t know how to put it to code :joy:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.