Hello, I am trying to create a repeating tweened GUI that stops once you click a text button. But, whenever I try out the script, the tween doesn't stop repeating even though I'm clicking the button. Roblox doesn't give me any errors as well.
This is in a Local Script.
while true do player.PlayerGui.MainGUI.AimBar.AimStick:TweenPosition( UDim2.new(0.951, 0, -0.5, 0), -- End Position "InOut", --EasingDirection "Sine", --EasingStyle 1, -- Time in seconds false, -- Override other tweens nil ) wait(1.01) player.PlayerGui.MainGUI.AimBar.AimStick:TweenPosition( UDim2.new(0.026, 0, -0.5, 0), -- End Position "InOut", --EasingDirection "Sine", --EasingStyle 1, -- Time in seconds false, -- Override other tweens nil ) wait(1.01) if Aimbar.ClickFrame.MouseButton1Up == true then break end end -- Script Continues
This may not be what you're looking for, but here we go!
local Player = game:GetService("Players").LocalPlayer --Getting The player(Localplayer is only for Localscripts!) local PlayerGui = Player:WaitForChild("PlayerGui")--getting the gui service (Player gui is only for localscripts!) local MainGUI = PlayerGui:WaitForChild("MainGUI") --getting screen gui local AimBar = MainGUI:WaitForChild("AimBar") -- getting aim bar local AimStick = AimBar:WaitForChild("AimStick") -- getting the AimStick --TweenSettings local TweenService = game:GetService("TweenService") local Positison = AimBar.Position local GoalPos = UDim2.new(1.11, 0,0.066, 0) --This will be where the gui moves(you can change the number) local tweenInfo = TweenInfo.new( 1.01, --wait time Enum.EasingStyle.Sine, --u know what this is Enum.EasingDirection.InOut,--u know what this is -1, --This will make it reapeat true, --This will make the tween go to its Goal postiton and go back to its Original postiton 0 --delytime ) local Animation = TweenService:Create(AimStick, tweenInfo, {Position = GoalPos}) --I dont know how to explan this very well sorry! Animation:Play() --This will play the animation AimStick.MouseButton1Up:Connect(function() Animation:Pause() --this will stop the animation(keep in mind the animation will never play) end)
I really recommend this video:https://youtu.be/DLI5yw0Rtc0