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 , 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.
local click = script.Parent.ClickDetector
if click.MouseClick == true then
door:PivotTo(CFrame.new(Vector3.new(-32.35, 15.2, 17.1)))
end```
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)
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.