Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UserInputService = game:GetService("UserInputService")
- local Players = game:GetService("Players")
- local TweenService = game:GetService("TweenService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Tool: Tool = script.Parent
- local Player = Players.LocalPlayer
- local PlayerGui = Player.PlayerGui
- local ActiveTween: Tween = nil
- local ActiveBobber: BasePart = nil
- local InWater = false
- local Clicked = true
- local IsShaking = false
- local Progress = 0
- local ToolEquipped = false
- local function CreateTween(Object: Instance, Info: TweenInfo, Properties)
- if ActiveTween then
- ActiveTween:Cancel()
- end
- local Tween = TweenService:Create(Object, Info, Properties)
- ActiveTween = Tween
- Tween:Play()
- return Tween
- end
- local function ResetProgressAndUI()
- Progress = 0
- Clicked = true
- InWater = false
- local Fishing = PlayerGui:WaitForChild("Fishing")
- if Fishing then
- local MainFrame = Fishing.Main
- if MainFrame then
- MainFrame.Casting.Visible = false
- local Bar = MainFrame.Casting.Bar
- if Bar then
- Bar.Size = UDim2.new(Bar.Size.X.Scale, 0, 0, 0)
- Bar.Position = UDim2.new(Bar.Position.X.Scale, 0, 1, 0)
- end
- end
- local ShakeFrame = MainFrame.ShakeFrame
- if ShakeFrame then
- for _, Button: ImageButton in pairs(ShakeFrame:GetChildren()) do
- if Button:IsA("ImageButton") and Button.Name ~= "Template" then
- Button:Destroy()
- end
- end
- end
- if ActiveBobber then
- ActiveBobber:Destroy()
- ActiveBobber = nil
- end
- if ActiveTween then
- ActiveTween:Cancel()
- ActiveTween = nil
- end
- end
- end
- local function UpdateBarColour(Bar: Frame)
- local Size = Bar.Size.Y.Scale
- local Red = math.clamp(1 - Size, 0, 1)
- local Green = math.clamp(Size, 0, 1)
- Bar.BackgroundColor3 = Color3.new(Red, Green, 0)
- end
- local function AnimateBar(Bar: Frame)
- Bar.Size = UDim2.new(Bar.Size.X.Scale, 0, 0, 0)
- Bar.Position = UDim2.new(Bar.Position.X.Scale, 0, 1, 0)
- local BarInfo = TweenInfo.new(
- 1,
- Enum.EasingStyle.Sine,
- Enum.EasingDirection.InOut,
- -1,
- true
- )
- local Tween = CreateTween(Bar, BarInfo, {
- Size = UDim2.new(Bar.Size.X.Scale, 0, 1, 0),
- Position = UDim2.new(Bar.Position.X.Scale, 0, 0, 0)
- })
- return Tween
- end
- local function Shake()
- if InWater and ToolEquipped and not IsShaking then
- IsShaking = true
- local ShakeFrame = PlayerGui:WaitForChild("Fishing").Main.ShakeFrame
- while Progress < 100 and IsShaking do
- repeat task.wait() until Clicked
- Clicked = false
- local ShakeClone = ShakeFrame.Template:Clone()
- local RandomX = math.random() * 0.9
- local RandomY = math.random() * 0.8
- ShakeClone.Position = UDim2.new(RandomX, 0, RandomY, 0)
- ShakeClone.Name = Progress
- ShakeClone.Visible = true
- ShakeClone.Parent = ShakeFrame
- local CanClick = true
- ShakeClone.MouseButton1Click:Connect(function()
- if Clicked then
- return
- end
- if CanClick and Progress < 100 then
- CanClick = false
- Clicked = true
- Progress += 5
- ShakeClone:Destroy()
- end
- end)
- end
- for _, Clone: ImageButton in pairs(ShakeFrame:GetChildren()) do
- if Clone:IsA("ImageButton") and Clone.Name == "Template" then
- continue
- end
- Clone:Destroy()
- end
- IsShaking = false
- end
- end
- UserInputService.InputBegan:Connect(function(Input: InputObject, GameProcessedEvent: boolean)
- if GameProcessedEvent then return end
- if ToolEquipped then
- if Input.UserInputType == Enum.UserInputType.MouseButton1 then
- ResetProgressAndUI()
- if ActiveBobber then
- ActiveBobber:Destroy()
- end
- local Fishing = PlayerGui:WaitForChild("Fishing")
- local MainFrame = Fishing.Main
- local Casting = MainFrame.Casting
- local Bar = Casting.Bar
- Casting.Visible = true
- AnimateBar(Bar)
- task.spawn(function()
- while Casting do
- UpdateBarColour(Bar)
- task.wait(0.1)
- end
- end)
- end
- end
- end)
- UserInputService.InputEnded:Connect(function(Input: InputObject, GameProcessedEvent: boolean)
- if GameProcessedEvent then return end
- if Input.UserInputType == Enum.UserInputType.MouseButton1 then
- local Fishing = PlayerGui:WaitForChild("Fishing")
- local MainFrame = Fishing.Main
- local Casting = MainFrame.Casting
- local Bar = Casting.Bar
- Casting.Visible = false
- if ActiveTween then
- ActiveTween:Cancel()
- end
- local Power = Bar.Size.Y.Scale * 70
- local Bobber = ReplicatedStorage:WaitForChild("Bobber"):Clone()
- local Rope = Bobber.Rope
- local Weld = Instance.new("Weld", Bobber)
- Weld.Part0 = script.Parent.Handle
- Weld.Part1 = Bobber
- Bobber.Position = script.Parent.Parent.PrimaryPart.Position + Vector3.new(-0.5, 8, -1)
- Bobber.Parent = script.Parent
- Rope.Attachment0 = script.Parent.Handle.Rod
- Rope.Attachment1 = Bobber.Bobber
- Bobber.Transparency = 0
- Rope.Visible = true
- local Velocity = Instance.new("BodyVelocity", Bobber)
- Velocity.MaxForce = Vector3.one * 100_000
- Velocity.Velocity = script.Parent.Parent.Head.CFrame.LookVector * Power
- Weld:Destroy()
- Bobber.Anchored = false
- Bar.Size = UDim2.new(Bar.Size.X.Scale, 0, 0, 0)
- Bar.Position = UDim2.new(Bar.Position.X.Scale, 0, 1, 0)
- ActiveBobber = Bobber
- task.delay(0.1, function()
- Velocity:Destroy()
- end)
- InWater = true
- Shake()
- end
- end)
- Tool.Equipped:Connect(function()
- ToolEquipped = true
- ResetProgressAndUI()
- end)
- Tool.Unequipped:Connect(function()
- ToolEquipped = false
- IsShaking = false
- ResetProgressAndUI()
- end)
Advertisement
Add Comment
Please, Sign In to add comment