RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"it doesnt work completely only for 2 clicks"
-- The reason it only works for two clicks is because you are setting the frame to be invisible after the second click. This makes it impossible to click the button again as it's now hidden. To fix this, you should not hide the frame, but instead move the button along with the frame. Here is the corrected script: local button = script.Parent local frame = script.Parent.Parent.Frame local tweenService = game:GetService('TweenService') local function onClick() if button.Text == '>' then button.Text = '<' local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out) local tween = tweenService:Create(frame, tweenInfo, {Position = UDim2.new(0.005, 0, 0.181, 0)}) tween:Play() elseif button.Text == '<' then button.Text = '>' local tweenInfo = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out) local tween = tweenService:Create(frame, tweenInfo, {Position = UDim2.new(-10, 0, 0.181, 0)}) tween:Play() end end button.MouseButton1Click:Connect(onClick)