local door = workspace.door1 script.Parent.ClickDetector.MouseClick:connect(function() for i = 40, 36, -.5 do door.Position = door.Position + Vector3.new(i, 0, 0) wait() end wait() end)
Well, that's what you're asking it to do!
sum = 0 for i = 40, 36, -.5 do sum = sum + i end print(sum) --342
This is equivalent to:
sum = 0 i = 40 sum = sum + i i = 39.5 sum = sum + i i = 39 sum = sum + i --... print(sum)
See the pattern? you're adding 40 and 39.5 to get 79.5. You then add 39 to 79.5 to get 118.5. Eventually, you have a sum of 342. So, your door moves about 342 studs out. Let's change that:
local door = workspace.door1 script.Parent.ClickDetector.MouseClick:connect(function() for i = 1, 9 do door.Position = door.Position + Vector3.new(1, 0, 0) wait() end wait() end)