I have a tool and when a player presses a button the tool will change it's position, but the tool will only move in one direction and will not head back to it's original spot.
Function moves tool to it's new spot and records the positions in two arrays
local gripPosArray = {} local gripRightArray = {} function scopeAnimationTo() for i = 1, 20 do wait() script.Parent.GripPos = script.Parent.GripPos + Vector3.new(0,0,-.025) table.insert(gripPosArray,i,script.Parent.GripPos) script.Parent.GripRight = script.Parent.GripRight + Vector3.new(0,0,-.1) table.insert(gripRightArray,i,script.Parent.GripRight) end print(script.Parent.GripPos) end
Function moves the tool back to origin using the array positions
function scopeAnimationFrom() for i = 1, 20 do wait() script.Parent.GripPos = gripPosArray[20-i] print(script.Parent.GripPos) script.Parent.GripRight = gripRightArray[20-i] end print(script.Parent.GripPos) end