Hey, i made a module which does tweening stuffs.
I have three button that has localscript to each.
the localscript calls the modulescript when mouseButton1Click
i dont really know how to explain the problem but, the tween back doesnt go back but goes to the recent position.
heres a vid which shows better the situation: https://gyazo.com/4f33ef6960f46082124837e1256e4fc8
module script:
local tweenService = game:GetService("TweenService")
local clickTime = 0.2
local module = {}
local ogPos = {}
local scaleX = 0.781
local function onMouseClickEnter(button, ogPos)
button:TweenPosition(UDim2.new(scaleX,0,ogPos.Y.Scale,0), "Out", "Sine", clickTime, true)
end
local function onMouseClickLeave(button, ogPos)
button:TweenPosition(UDim2.new(1.1, 0,ogPos.Y.Scale,0), "Out", "Sine", clickTime, true)
end
function module.enter(button)
if not table.find(ogPos, button) then
ogPos[button] = button.Position
end
local mainPos = ogPos[button]
onMouseClickEnter(button, mainPos)
function module.leave(button)
onMouseClickLeave(button, mainPos)
end
end
return module
local script:
btw, its the same script to all buttons but the gui ,that the variable ‘frame’ calls out, changed.
local module = require(game:GetService("ReplicatedStorage"):WaitForChild("clickFrameUI"))
local frame = script.Parent.Parent.changeWalkSpeed
frame.Position = UDim2.new(1.1, 0,frame.Position.Y.Scale,0)
local clicked
script.Parent.MouseButton1Click:Connect(function()
clicked = not clicked
if clicked then
module.enter(frame)
else
module.leave(frame)
end
end)