Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --// Services
- local TweenService = game:GetService("TweenService")
- --// Variables
- local Player = game.Players.LocalPlayer
- local Main = workspace.DoublePhysicsDoor.Frame.Main
- local Frame = Player.PlayerGui:WaitForChild("LockpickingUI").Frame
- local MainFrame = Frame.MainFrame
- local Button = MainFrame.Button
- local Line = MainFrame.Line
- local Debounce
- --// Connections
- Main.ProximityPrompt.Triggered:Connect(function()
- if Debounce then return end
- Debounce = true
- Frame.Visible = true
- local Connection
- local ShouldTweensRun = true
- coroutine.wrap(function()
- local RandomNumber = math.random(4,8)
- for i = 1, RandomNumber do
- local TimeForTween = Random.new():NextNumber(1,1.5)
- local _TweenInfo = TweenInfo.new(TimeForTween, Enum.EasingStyle.Linear)
- local TweenUp = TweenService:Create(Line, _TweenInfo, {Position = UDim2.new(0.012,0,0, 0)})
- local TweenDown = TweenService:Create(Line, _TweenInfo, {Position = UDim2.new(0.012,0,0.989, 0)})
- ShouldTweensRun = true
- Connection = Button.MouseButton1Click:Connect(function()
- local ButtonPosY = Button.Position.Y.Scale
- local LinePosY = Line.Position.Y.Scale
- if LinePosY <= ButtonPosY + Button.Size.Y.Scale and LinePosY >= ButtonPosY then
- ShouldTweensRun = false
- Connection:Disconnect()
- else
- ShouldTweensRun = false
- Frame.Visible = false
- Debounce = false
- Connection:Disconnect()
- end
- end)
- while ShouldTweensRun do
- TweenUp:Play()
- wait(TimeForTween)
- TweenDown:Play()
- wait(TimeForTween)
- end
- if not Frame.Visible then
- break
- end
- end
- if Frame.Visible then
- game.ReplicatedStorage.LockpickingEvent:FireServer()
- Frame.Visible = false
- Debounce = false
- end
- end)
- while Frame.Visible do
- wait(.5)
- local Character = Player.Character or Player.CharactedAdded:Wait()
- if (Character.HumanoidRootPart.Position - Main.Position).Magnitude > 15 then
- Connection:Disconnect()
- ShouldTweensRun = false
- Debounce = false
- Frame.Visible = false
- end
- end
- end)
Add Comment
Please, Sign In to add comment