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 first half of the script. The second half is the same numbers but the negative counterpart.
Edit This door is a stove door that reacts through clicking to open it. in case this changes anyones answers.
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)

3 comments
It'll save you a lot of trouble later on if you want to change something if you make a for loop for every time you change the CFrame rather than calling CFrame a bunch of times.
Yes ^
I'm not sure how to loop. I'll try to look into it thanks for the heads up! I'm guessing this is to clean up my script not fix the positioning problem correct?