Hello, I’m making a keycode door where the door opens when the right code is entered. I can’t seem to make the door rotate. This is what I’m trying to rotate it to:
Here is the script I used for the enter button that should (hopefully) trigger it.
db = false
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if db == false then
db = true
script.Parent.Position = script.Parent.Position + Vector3.new(0.05,0,0)
script.Parent.Beep:Play()
if script.Parent.Parent.CodeShower.SurfaceGui.TextLabel.Text == script.Parent.Parent.Code.Value then
game.Workspace.Door1.Activate.Value = true
script.Parent.Parent.CodeShower.SurfaceGui.TextLabel.Text = "CORRECT"
else
script.Parent.Parent.CodeShower.SurfaceGui.TextLabel.Text = "INCORRECT"
end
wait(0.1)
script.Parent.Position = script.Parent.Position - Vector3.new(0.05,0,0)
wait(2)
script.Parent.Parent.CodeShower.SurfaceGui.TextLabel.Text = ""
db = false
end
end)
Inside the door model, I placed a BoolValue named “Activate” which is set to true once the correct code is entered. Please note that prior to this, I tested it with a door with a single part that sets collision to off so you can walk through it once the code is entered. I built a door, grouped it as a model, now I don’t know what to do since there’s a bunch of parts. Here is the script I placed under the BoolValue:
local model = script.Parent.Parent
local Pivot = model:GetPivot()
script.Parent.Parent:WaitForChild("Activate")
while true do
if script.Parent.Value == true then
task.wait()
Pivot *= CFrame.Angles(0,math.rad(25),0)
wait(0.1)
Pivot += CFrame.Angles(0,math.rad(25),0)
wait()
script.Parent.Value = false
end
end
Inside the model, I also put this:
local model = script.Parent
model.PrimaryPart = script.Parent.Main
Main contains all the detailed parts of the door. Any help is appreciated, thank you.