Lo202
|
  |
| Joined: 31 Jan 2013 |
| Total Posts: 579 |
|
|
| 14 Dec 2015 02:13 AM |
Why can't I hold and dig? I wanna make one like quarry.
wait(0)
local Players = game:GetService("Players") local Workspace = game:GetService("Workspace") local ReplicatedStorage = game:GetService("ReplicatedStorage") local ServiceModule = ReplicatedStorage.ServiceModule
-- Retrieve server modules required
local wait = require(ServiceModule.WaitModule) local crypt = require(ServiceModule.CryptModule)
local Player = Players.LocalPlayer local Backpack = Player.Backpack local PlayerGui = Player.PlayerGui local Animated = Backpack:FindFirstChild("ReAnimate") local gui = PlayerGui:FindFirstChild("GameGUI")
-- Reanimate the pickaxe (fix animation not working)
if not Animated.Value then local p = script.Parent:FindFirstChild("Active") if p then p.Disabled = false Workspace.Generation.AnimateFix:InvokeServer() end end
-- Setting vars for stuff
local debounce = true local checkPad = false local confirmDig = false local activePick = false local isMining = false local invFull = false local cancel = false local success = false local enc1 = {29, 58, 93, 28, 27}
repeat wait() until Player.Character
local plrSpeed = 16 local Humanoid = Player.Character.Humanoid local Tool = script.Parent local AnimSlash = Tool.RightSlash local DigSound = Tool.Handle.Dig local Settings = Tool.Settings local Speed = Settings.SpeedWalk local waitStone = Settings.HitStone local waitDirt = Settings.HitDirt local waitOre = Settings.HitOre local waitGranite = Settings.HitGranite local waitObsidian = Settings.HitObsidian local coolDown = Settings.CoolDown local targetRange = Settings.HitRange
local cGui = PlayerGui["StatsGUI"] local Inventory = cGui.InventoryFrame.Inventory local BarInfo = cGui.ProgressFrame.TextBar.TextLabel
local pickSound = "http://www.roblox.com/asset?id=157176648"
repeat wait() until Player:FindFirstChild("Animate")
-- Play RightSlash when animate is true
Player.Animate.Changed:connect(function() if Player.Animate.Value then local SlashAnim = Humanoid:LoadAnimation(AnimSlash) SlashAnim:Play() end end)
Workspace.Generation.ToolEffect:InvokeServer()
-- Create a SelectionBox for block selection
local SelectionSurface = Instance.new("SelectionBox") SelectionSurface.Color = BrickColor.Green() SelectionSurface.Visible = true SelectionSurface.Parent = PlayerGui SelectionSurface.Adornee = nil
function findItem(inv, ore) if inv:FindFirstChild("En_"..ore) then return tonumber((crypt(tostring(inv["En_"..ore].Value),enc1,true))) or 0 else return 0 end end
function checkInventory() if Inventory.Value >= Inventory.MaxValue then invFull = true BarInfo.Text = "INVENTORY IS FULL" BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,35),UDim2.new(0, 0, -1, -5), "Out", "Quad", 0.075, true) elseif Inventory.Value < Inventory.MaxValue then invFull = false end end
local function onMouseButton1Down(mouse) local target = mouse.Target local surface = mouse.TargetSurface local tarRange = (targetRange.Value/2) + 16 checkInventory() confirmDig = true checkPad = false if target and target.Parent == Workspace.BlockField and target.Locked == false then if target:FindFirstChild("Teled") then if target["Teled"].Value == Player.Name then checkPad = true else if Players:FindFirstChild(target["Teled"].Value) then confirmDig = false end end end if target:FindFirstChild("Claimed") then if target["Claimed"].Value == Player.Name then checkPad = true else if Players:FindFirstChild(target["Claimed"].Value) then confirmDig = false end end end end if (target and target.Parent == Workspace.BlockField and target.Locked == false and not target:FindFirstChild("Owner") and not isMining and not invFull and confirmDig) then if not target.Locked and (target.Position-Tool.Handle.Position).magnitude <= tarRange and debounce then debounce = false local hitObj = target.Name if checkPad then -- place checkpoint pad end isMining = true if not cancel and Humanoid.Health > 0 then local SlashAnim = Humanoid:LoadAnimation(AnimSlash) SlashAnim:Play() BarInfo.Text = "MINING "..string.upper(target.Name) BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,35),UDim2.new(0, 0, -1, -5), "Out", "Quad", 0.075, true) Humanoid.WalkSpeed = plrSpeed/3 SelectionSurface.Adornee = target SelectionSurface.Color = BrickColor.White() local delay = waitOre.Value if target.Name == "Stone" then delay = waitStone.Value elseif target.Name == "Dirt" then delay = waitDirt.Value elseif target.Name == "Granite" then if waitGranite.Value == 0 then delay = 1.2 else delay = waitGranite.Value end elseif target.Name == "Obsidian" then if waitObsidian.Value == 0 then delay = 2.5 else delay = (waitObsidian.Value * 1.5) end else delay = waitOre.Value end if not target:FindFirstChild("Decal") then cGui.ProgressFrame.TopBar:TweenSizeAndPosition(UDim2.new(1,0,1,0),UDim2.new(0, 0, 0, 0), "InOut", "Linear", delay*6,true) local ended = surface local placed = nil if target:FindFirstChild("Placed") then placed = target.Placed.Value end Workspace.DigHandler.Claim:InvokeServer(ended, target, delay, placed) --ServerFunction.DigBlock:InvokeServer(ended,target,delay) success = true end end if not cancel then Humanoid.WalkSpeed = plrSpeed if success and hitObj == target.Name then --local oldNum = findItem(Player.playerstats.data.inventory,hitObj) DigSound.Pitch = 1 DigSound.SoundId = pickSound DigSound:Play() --BarInfo.Text = string.upper(target.Name).. " x"..tostring(oldNum) else BarInfo.Text = "CANNOT MINE THIS BLOCK" SelectionSurface.Color = BrickColor.Red() end elseif cancel or Humanoid.Health == 0 then Humanoid.WalkSpeed = plrSpeed local x = target:GetChildren() for v = 1, #x do if x[v].Parent == Workspace.BlockField and x[v]:IsA("Decal") or x[v]:IsA("StringValue") then x[v]:Destroy() end end end Humanoid.WalkSpeed = plrSpeed SelectionSurface.Adornee = nil BarInfo.Text = " " BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,0),UDim2.new(0, 0, 1, -5), "Out", "Quad", 0.3, true) cGui.ProgressFrame.TopBar:TweenSizeAndPosition(UDim2.new(0,0,1,0),UDim2.new(0.5, 0, 0, 0), "InOut", "Linear", coolDown.Value,true) wait(coolDown.Value) debounce = true isMining = false end elseif not isMining and not invFull then if target and target:FindFirstChild("Owner") then if target["Owner"].Value ~= Player.Name and Players:FindFirstChild(target["Owner"].Value) then BarInfo.Text = string.upper(tostring(target["Owner"].Value)).. " IS MINING THIS" Humanoid.WalkSpeed = plrSpeed SelectionSurface.Color = BrickColor.Red() end elseif target and target:FindFirstChild("Teled") then if target["Teled"].Value ~= Player.Name and Players:FindFirstChild(target["Teled"].Value) then BarInfo.Text = string.upper(tostring(target["Teled"].Value)).. "'S CHECKPOINT" Humanoid.WalkSpeed = plrSpeed SelectionSurface.Color = BrickColor.Red() end elseif target and target:FindFirstChild("Claimed") then if target["Claimed"].Value ~= Player.Name and Players:FindFirstChild(target["Claimed"].Value) then BarInfo.Text = string.upper(tostring(target["Claimed"].Value)).. " CLAIMED THIS" Humanoid.WalkSpeed = plrSpeed SelectionSurface.Color = BrickColor.Red() end elseif target then local x = target:GetChildren() Humanoid.WalkSpeed = plrSpeed for v = 1, #x do if x[v].Parent == Workspace.BlockField and x[v]:IsA("Decal") or x[v]:IsA("StringValue") then x[v]:Destroy() end end end elseif invFull then BarInfo.Text = "INVENTORY IS FULL" BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,35),UDim2.new(0, 0, -1, -5), "Out", "Quad", 0.075, true) end end
local function onMouseMoved(mouse) checkInventory() if debounce and not isMining and not invFull then local target = mouse.Target local surface = mouse.TargetSurface local tarRange = (targetRange.Value/2) + 16 if target then if not target.Locked and (target.Position-Tool.Handle.Position).magnitude <= tarRange then if target.Anchored then SelectionSurface.Adornee = target SelectionSurface.Color = BrickColor.Green() local owned = target:FindFirstChild("Owner") local teled = target:FindFirstChild("Teled") local claim = target:FindFirstChild("Claimed") if owned and owned.Value ~= Player.Name and Players:FindFirstChild(owned.Value) then BarInfo.Text = string.upper(tostring(owned.Value)).. " IS MINING THIS" SelectionSurface.Color = BrickColor.Red() elseif teled and teled.Value == Player.Name then BarInfo.Text = "REMOVE CHECKPOINT" elseif teled and teled.Value ~= Player.Name and Players:FindFirstChild(teled.Value) then BarInfo.Text = string.upper(tostring(teled.Value)).. "'S CHECKPOINT" SelectionSurface.Color = BrickColor.Red() elseif claim and claim.Value ~= Player.Name and Players:FindFirstChild(claim.Value) then BarInfo.Text = string.upper(tostring(claim.Value)).. " CLAIMED THIS" SelectionSurface.Color = BrickColor.Red() else BarInfo.Text = string.upper(target.Name) BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,35),UDim2.new(0, 0, -1, -5), "Out", "Quad", 0.075, true) end else wait() SelectionSurface.Adornee = nil BarInfo.Text = " " BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,0),UDim2.new(0, 0, 1, -5), "Out", "Quad", 0.3, true) end else wait() SelectionSurface.Adornee = nil BarInfo.Text = " " BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,0),UDim2.new(0, 0, 1, -5), "Out", "Quad", 0.3, true) end end end end
function onSelected(mouse) checkInventory() if not activePick then activePick = true cancel = false cGui["ProgressFrame"]:TweenPosition(UDim2.new(0.5, -85, 1, -90), "Out", "Elastic", 0.5, true) BarInfo.Text = " " BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,0),UDim2.new(0, 0, 1, -5), "Out", "Quad", 0.3, true) mouse.Icon = "http://www.roblox.com/asset/?id=81886844" gui["Tool1"].ToolSelected.Value = true if gui["Tools"].Value == 1 then gui["Tool1"]:TweenSizeAndPosition(UDim2.new(0,70,0,70),UDim2.new(0.5, -65, 1, -75), "Out", "Quad", 0.075,true) elseif gui["Tools"].Value == 3 then gui["Tool1"]:TweenSizeAndPosition(UDim2.new(0,70,0,70),UDim2.new(0.5, -125, 1, -75), "Out", "Quad", 0.075,true) end plrSpeed = Workspace.Generation.Speed:InvokeServer() Workspace.Generation.ToolEffect:InvokeServer() mouse.Move:connect(function() onMouseMoved(mouse) end) mouse.Button1Down:connect(function() onMouseButton1Down(mouse) end) end end
function onDeselected(mouse) if activePick then activePick = false cGui["ProgressFrame"]:TweenPosition(UDim2.new(0.5, -85, 1, 100), "Out", "Quad", 0.5, true) BarInfo.Text = " " BarInfo.Parent:TweenSizeAndPosition(UDim2.new(1,0,0,0),UDim2.new(0, 0, 1, -5), "Out", "Quad", 0.3, true) gui["Tool1"].ToolSelected.Value = false if gui["Tools"].Value == 1 then gui["Tool1"]:TweenSizeAndPosition(UDim2.new(0,60,0,60),UDim2.new(0.5, -60, 1, -70), "Out", "Quad", 0.075,true) elseif gui["Tools"].Value == 3 then gui["Tool1"]:TweenSizeAndPosition(UDim2.new(0,60,0,60),UDim2.new(0.5, -120, 1, -70), "Out", "Quad", 0.075,true) end cancel = true SelectionSurface.Adornee = nil end end
Tool.Equipped:connect(onSelected) Tool.Unequipped:connect(onDeselected)
|
|
|
| Report Abuse |
|