Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get this door to close and open in the same position?

Asked by 7 years ago
Edited 7 years ago

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)
0
Please, use LUA code block so we can easier read your code. deris88 146 — 7y
0
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. launcelothandsome 0 — 7y
0
Nevermind figured it out :D launcelothandsome 0 — 7y

Answer this question