Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I Make An Automine Pickaxe?

Asked by 4 years ago

Okay, I I Have A Mining Script For A Pickaxe That I Made, So How Do I Make It Go Automatic Without Wrecking The Script?

local tType = script.Parent:FindFirstChild("TType")
local count = tType:FindFirstChild("Count").Value
local range = tType:FindFirstChild("Range").Value
local damage = tType:FindFirstChild("Damage").Value
local coolDown = tType:FindFirstChild("coolDown").Value

--------------------------------------------------------

local plr = game.Players.LocalPlayer
repeat wait() until plr.Character ~= nil
local mouse = plr:GetMouse()
local rs = game:GetService('ReplicatedStorage')
local events = rs.Events
local st = plr:WaitForChild("Settings")
local blocks = st:WaitForChild("Blocks")
local char = plr.Character
local pack = nil
local area = nil
pcall(function()
    pack = char:FindFirstChild("Backpack")
    area = pack:FindFirstChild("MaxArea")
end)


local basili = false

mouse.Button1Down:Connect(function()
    basili = true
end)

mouse.Button1Up:Connect(function()
    basili = false
end)

pcall(function()
wait(0.01)
while wait(coolDown) do
    wait(0.01)
    pack = char:FindFirstChild("Backpack")
    area = pack:FindFirstChild("MaxArea")
    if script.Parent.Parent.Name ~= "Backpack" and script.Parent.Parent.Name == plr.Name then
        if mouse.Target and mouse.Target.Parent.Name == "Ore" then
            local mag = (mouse.Target.Position-plr.Character.HumanoidRootPart.Position).magnitude
            if mag <= range then
                if mouse.Target and mouse.Target.Parent.Name == "Ore" then
                    plr.PlayerGui.BlockInfo.Enabled = true
                    plr.PlayerGui.SelectionBox.Color3 = Color3.new(0,255,0)
                    plr.PlayerGui.SelectionBox.Adornee = mouse.Target
                    if mouse.Target.CurrentDamage.Value/mouse.Target.Damage.Value > 1 then
                        plr.PlayerGui.BlockInfo.Frame.Fill.Size = UDim2.new(1,0,1,0)
                    else
                        plr.PlayerGui.BlockInfo.Frame.Fill.Size = UDim2.new(mouse.Target.CurrentDamage.Value/mouse.Target.Damage.Value,0,1,0)
                    end
                    plr.PlayerGui.BlockInfo.Frame.BlockName.Text = mouse.Target.Name.." - "..mouse.Target.Count.Value
                    plr.PlayerGui.BlockInfo.Frame.Value.Text = "Value: "..mouse.Target.Coin.Value
                else
                    plr.PlayerGui.BlockInfo.Enabled = false
                    plr.PlayerGui.SelectionBox.Adornee = nil
                    script.Parent.Handle.Breaking:Stop()
                end
                if basili then
                    if (area.Value-blocks.Value) > 0 then
                    else
                        if plr.PlayerGui:FindFirstChild("Sell/Upgrade") then
                            plr.PlayerGui:FindFirstChild("Sell/Upgrade").Frame.Visible = true
                        end
                    end
                    if mouse.Target and mouse.Target.Parent.Name == "Ore" then
                        if mouse.Target.CurrentDamage.Value >= mouse.Target.Damage.Value then
                            events.Break:FireServer(mouse.Target,count)
                            mouse.Target.CurrentDamage.Value = 0
                            script.Parent.Handle.Breaking:Stop()
                        end
                        mouse.Target.CurrentDamage.Value = mouse.Target.CurrentDamage.Value + damage
                        if script.Parent.Handle.Breaking.Playing == false then
                            script.Parent.Handle.Breaking:Play()
                        else                
                        end
                    end
                    for i,v in pairs(workspace.Ore:GetChildren()) do
                        if v ~= mouse.Target then
                            if v:FindFirstChild("CurrentDamage") == nil then
                                return
                            else
                                v:FindFirstChild("CurrentDamage").Value = 0
                            end
                        end
                    end
                else
                    script.Parent.Handle.Breaking:Stop()
                    for i,v in pairs(workspace.Ore:GetChildren()) do
                        if v:FindFirstChild("CurrentDamage") == nil then
                            return
                        else
                            v:FindFirstChild("CurrentDamage").Value = 0
                        end
                    end
                end
            else
                plr.PlayerGui.BlockInfo.Enabled = true
                plr.PlayerGui.SelectionBox.Color3 = Color3.new(255,0,0)
                plr.PlayerGui.SelectionBox.Adornee = mouse.Target
                plr.PlayerGui.BlockInfo.Frame.Fill.Size = UDim2.new(0,0,1,0)
                plr.PlayerGui.BlockInfo.Frame.BlockName.Text = "Out of range!"
                plr.PlayerGui.BlockInfo.Frame.Value.Text = "Value: "..0
                script.Parent.Handle.Breaking:Stop()
                for i,v in pairs(workspace.Ore:GetChildren()) do
                    if v:FindFirstChild("CurrentDamage") == nil then
                        return
                    else
                        v:FindFirstChild("CurrentDamage").Value = 0
                    end
                end
            end
        elseif mouse.Target and mouse.Target.Parent.Parent.Name == "Ore" then
            local mag = (mouse.Target.Parent.Position-plr.Character.HumanoidRootPart.Position).magnitude
            if mag <= range then
                if mouse.Target.Parent and mouse.Target.Parent.Parent.Name == "Ore" then
                    plr.PlayerGui.BlockInfo.Enabled = true
                    plr.PlayerGui.SelectionBox.Color3 = Color3.new(0,255,0)
                    plr.PlayerGui.SelectionBox.Adornee = mouse.Target.Parent
                    if mouse.Target.Parent.CurrentDamage.Value/mouse.Target.Parent.Damage.Value > 1 then
                        plr.PlayerGui.BlockInfo.Frame.Fill.Size = UDim2.new(1,0,1,0)
                    else
                        plr.PlayerGui.BlockInfo.Frame.Fill.Size = UDim2.new(mouse.Target.Parent.CurrentDamage.Value/mouse.Target.Parent.Damage.Value,0,1,0)
                    end
                    plr.PlayerGui.BlockInfo.Frame.BlockName.Text = mouse.Target.Parent.Name.." - "..mouse.Target.Parent.Count.Value
                    plr.PlayerGui.BlockInfo.Frame.Value.Text = "Value: "..mouse.Target.Parent.Coin.Value
                else
                    plr.PlayerGui.BlockInfo.Enabled = false
                    plr.PlayerGui.SelectionBox.Adornee = nil
                    script.Parent.Handle.Breaking:Stop()
                end
                if basili then
                    if (area.Value-blocks.Value) > 0 then
                    else
                        if plr.PlayerGui:FindFirstChild("Sell/Upgrade") then
                            plr.PlayerGui:FindFirstChild("Sell/Upgrade").Frame.Visible = true
                        end
                    end
                    if mouse.Target.Parent and mouse.Target.Parent.Parent.Name == "Ore" then
                        if mouse.Target.Parent.CurrentDamage.Value >= mouse.Target.Parent.Damage.Value then
                            events.Break:FireServer(mouse.Target.Parent,count)
                            mouse.Target.Parent.CurrentDamage.Value = 0
                            script.Parent.Handle.Breaking:Stop()
                        end
                        mouse.Target.Parent.CurrentDamage.Value = mouse.Target.Parent.CurrentDamage.Value + damage
                        if script.Parent.Handle.Breaking.Playing == false then
                            script.Parent.Handle.Breaking:Play()
                        else                
                        end
                    end
                    for i,v in pairs(workspace.Ore:GetChildren()) do
                        if v ~= mouse.Target.Parent then
                            if v:FindFirstChild("CurrentDamage") == nil then
                                return
                            else
                                v:FindFirstChild("CurrentDamage").Value = 0
                            end
                        end
                    end
                else
                    script.Parent.Handle.Breaking:Stop()
                    for i,v in pairs(workspace.Ore:GetChildren()) do
                        if v:FindFirstChild("CurrentDamage") == nil then
                            return
                        else
                            v:FindFirstChild("CurrentDamage").Value = 0
                        end
                    end
                end
            else
                plr.PlayerGui.BlockInfo.Enabled = true
                plr.PlayerGui.SelectionBox.Color3 = Color3.new(255,0,0)
                plr.PlayerGui.SelectionBox.Adornee = mouse.Target.Parent
                plr.PlayerGui.BlockInfo.Frame.Fill.Size = UDim2.new(0,0,1,0)
                plr.PlayerGui.BlockInfo.Frame.BlockName.Text = "Out of range!"
                plr.PlayerGui.BlockInfo.Frame.Value.Text = "Value: "..0
                script.Parent.Handle.Breaking:Stop()
                for i,v in pairs(workspace.Ore:GetChildren()) do
                    if v:FindFirstChild("CurrentDamage") == nil then
                        return
                    else
                        v:FindFirstChild("CurrentDamage").Value = 0
                    end
                end
            end
        else
            plr.PlayerGui.BlockInfo.Enabled = false
            plr.PlayerGui.SelectionBox.Adornee = nil
            script.Parent.Handle.Breaking:Stop()
            for i,v in pairs(workspace.Ore:GetChildren()) do
                if v:FindFirstChild("CurrentDamage") == nil then
                    return
                else
                    v:FindFirstChild("CurrentDamage").Value = 0
                end
            end
        end
    else
        plr.PlayerGui.BlockInfo.Enabled = false
        plr.PlayerGui.SelectionBox.Adornee = nil
        script.Parent.Handle.Breaking:Stop()
    end
end
end)
0
I am a small scripter who can't figure this out ;-; hasanchik 49 — 4y

Answer this question