I'm very new to scripting and i'm trying to figure out C frames and how they function with doors. I have a door that opens but when it closes it is slightly off. Each time it opens and closes the door moves slightly further off until eventually it is far askew. I have tried tinkering with the numbers to get it to move minimally. However, it is always atleast a bit off. here is the script i have
function onClicked()
if script.Parent.Value.Value == true then
script.Parent.Value.Value = false
wait(0)
script.Parent.smoke.ParticleEmitter.Enabled = true
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, 0.22) * CFrame.fromEulerAnglesXYZ(0, 0.1, 0)
wait(0.01)
wait(1)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(0.01)
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0, -0.22) * CFrame.fromEulerAnglesXYZ(0, -0.1, 0)
wait(1)
script.Parent.smoke.ParticleEmitter.Enabled = false
script.Parent.Value.Value = true
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

3 comments
Please, use LUA code block so we can easier read your code.
Would you care to explain how to do that please :D I'm new to this forum but i'd be happy to reformat to make it easier to read.
Nevermind figured it out :D