Basicly if you mine a block where there is sky it just breaks.
function BoxDetermination(Target, distance)
if distance <= 20 then
BoxSelection.Adornee = Target
BoxSelection.Color3 = Color3.fromRGB(100, 255, 16)
OreFrame.Visible = true
CanMine = true
local Targeted = tostring(Target)
--Changing Information
OreFrame.Ore.Text = tostring(Target).." - "..tostring(Target.Ore.Value)
OreFrame.Ore.TextColor3 = OreModule[Targeted]["OreColor"]
OreFrame.Front.Bar.BackgroundColor3 = OreModule[Targeted]["OreColor"]
OreFrame.Front.Bar1.BackgroundColor3 = OreModule[Targeted]["DarkOreColor"]
OreFrame.CoinValue.Text = "Coin Value: "..tostring(OreModule[Targeted]["CoinValue"])
else
BoxSelection.Adornee = Target
BoxSelection.Color3 = Color3.fromRGB(255, 42, 42)
OreFrame.Visible = true
CanMine = false
--Changing Information
OreFrame.Ore.Text = "Far from range"
OreFrame.Ore.TextColor3 = Color3.fromRGB(255, 42, 42)
OreFrame.Front.Bar.BackgroundColor3 = Color3.fromRGB(255, 42, 42)
OreFrame.Front.Bar1.BackgroundColor3 = Color3.fromRGB(166, 27, 27)
OreFrame.CoinValue.Text = ""
end
end
function RepeatMine(Target)
local Bar = OreFrame.Front.Bar
while wait() do
if Target == nil then
print("BRaey")
end
Bar:TweenSize(UDim2.new(0.948, 0, 0.735, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, Time, false)
if CanMine == false or hold == false or Mining == false or TheChange == false then
Bar:TweenSize(UDim2.new(0.027, 0, 0.735, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.01, true)
break
else
if Bar.Size.X.Scale > 0.9 then
RemoteEvent:FireServer(BoxSelection.Adornee)
Bar:TweenSize(UDim2.new(0.027, 0, 0.735, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.01, true)
end
end
end
end
Mouse.Idle:Connect(function()
local Targ = Mouse.Target
spawn(function()
if Targ and Targ.Parent then
if tostring(Targ.Parent) == "BlockField" and hold == true then
OreFrame.Visible = false
local distance = (Handle.CFrame.Position - Targ.CFrame.Position).Magnitude
BoxDetermination(Targ, distance)
else
OreFrame.Visible = false
BoxSelection.Adornee = nil
end
end
end)
end)
Mouse.Button1Up:Connect(function()
Mining = false
end)
Mouse.Button1Down:Connect(function()
Mining = true
TheChange = true
spawn(function()
while wait() do
local Targ = Mouse.Target
if hold == true and Mining == true and Targ and Targ.Parent and tostring(Targ.Parent) == "BlockField" then
RepeatMine(Targ)
end
end
end)
end)
Tool.Equipped:Connect(function()
hold = true
end)
Tool.Unequipped:Connect(function()
hold = false
OreFrame.Visible = false
end)
BoxSelection:GetPropertyChangedSignal("Adornee"):Connect(function(Thing)
TheChange = true
local Bar = OreFrame.Front.Bar
if BoxSelection.Adornee == nil then
return
else
Time = tonumber(OreModule[tostring(BoxSelection.Adornee)]["Time"])
print(Time)
Bar:TweenSize(UDim2.new(0.027, 0, 0.735, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.01, true)
end
end)