and here is the rocks script:
--Services
local ss = game:GetService("ServerStorage")
local sss = game:GetService("ServerScriptService")
--LootTable
local Common = 1000 --1
local Uncommon = 500 --2
local Rare = 200 --3
local UltraRare = 35 --4
local Legendary = 10 --5
local Mythic = 0.2 --6
local Drops = {
--Ores
--Common
{Name = "Coal"},
{Name = "Copper"},
{Name = "Iron"},
{Name = "Lead"},
{Name = "Tin"},
--Uncommon
{Name = "Amber"},
{Name = "Gold"},
{Name = "Platinum"},
{Name = "Sapphire"},
{Name = "Topaz"},
{Name = "Tungesten"},
--Rare
{Name = "Cobalt"},
{Name = "Diamond"},
{Name = "Emerald"},
{Name = "Garnet"},
{Name = "Onyx"},
{Name = "Ruby"},
{Name = "SkyBlueTopaz"},
--Crystals
--Uncommon
{Name = "Sapphire Crystal"},
{Name = "Rhodolite"},
{Name = "Amethyst Crystal"},
--Rare
{Name = "Clear Quartz"},
{Name = "Sky Blue Topaz"},
--UltraRare
{Name = "Amethyst Airs Quartz"},
{Name = "Crystallized Diamond"},
{Name = "Crystallized Emerald"},
{Name = "Black Kinitaenite"},
{Name = "Spessartite Garnet"},
--Legendary
{Name = "Enchanted Luzi"},
{Name = "Enchanted Rose Qaurtz"},
{Name = "Hallowed Crystal"},
}
local OreLootTable = {
--Common Drops
{Item = Drops[1], Weight = Common}, --Coal
{Item = Drops[2], Weight = Common}, --Copper
{Item = Drops[3], Weight = Common}, --Iron
{Item = Drops[4], Weight = Common}, --Lead
{Item = Drops[5], Weight = Common}, --Tin
--Uncommon Drops
{Item = Drops[6], Weight = Uncommon}, --Amber
{Item = Drops[7], Weight = Uncommon}, --Gold
{Item = Drops[8], Weight = Uncommon}, --Platinum
{Item = Drops[9], Weight = Uncommon}, --Sapphire
{Item = Drops[10], Weight = Uncommon}, --Topaz
{Item = Drops[11], Weight = Uncommon}, --Tungesten
--Rare Drops
{Item = Drops[12], Weight = Rare}, --Cobalt
{Item = Drops[13], Weight = Rare}, --Diamond
{Item = Drops[14], Weight = Rare}, --Emerald
{Item = Drops[15], Weight = Rare}, --Garnet
{Item = Drops[16], Weight = Rare}, --Onyx
{Item = Drops[17], Weight = Rare}, --Ruby
{Item = Drops[18], Weight = Rare}, --Sky Blue Topaz
}
local CrystalLootTable = {
--Uncommon Drops
{Item = Drops[19], Weight = Uncommon}, --Sapphire Crystal
{Item = Drops[20], Weight = Uncommon}, --Rhodolite
{Item = Drops[21], Weight = Uncommon}, --Amethyst Crystal
--Rare Drops
{Item = Drops[22], Weight = Rare}, --Clear Quartz
{Item = Drops[23], Weight = Rare}, --Sky Blue Topaz
}
for i,Rock in pairs((script.Parent:GetChildren())) do --Will Get all of the Rocks
if(Rock:IsA("BasePart")) then --Will Test if the Rock is a Part
if(Rock:FindFirstChild("Health"))then
local label = Rock.HealthInfo
local hit_sound = Rock.Parent.Hit
local rockPos = Rock.Position
local Health = Rock.Health
local MaxHealth = Rock.MaxHealth
local RockMined = Rock.Mined.Value
local debounce = false
--Mining Manager
Rock.Touched:Connect(function(otherPart)
local tool = otherPart.Parent
if tool:IsA('Tool') and tool.Mining.Value == true then
if debounce == false then
debounce = true
local damage = tool.Damage.Value
hit_sound:Play()
Health.Value = Health.Value - damage
local playersHasMined = Rock:FindFirstChild("Folder") or Instance.new("Folder",Rock)
local playervalue = playersHasMined:FindFirstChild(tool.Parent.Name) or Instance.new("BoolValue",Rock)
playervalue.Name = tool.Parent.Name
label.TextLabel.Text = Health.Value.."/"..MaxHealth.Value
if Rock.Health.Value <= 0 then
if RockMined == false then
RockMined = true
local stone = ss.Drops.Normal:WaitForChild("Stone")
--Stone Generator
for i = 1, math.random(1,4) do --Grabs a random number between 1-4 and begins a loop
local clone = stone:Clone() --Clones the Stone 1-4 times
clone.Parent = workspace --The Cloned Stones appear in the Workspace
if clone:IsA("Model")then
clone.PrimaryPart.Position = rockPos --The Clones Stones will appear at the rock that was mined
elseif clone:IsA("BasePart")then
clone.Position = rockPos --The Clones Stones will appear at the rock that was mined
end
end
if Rock.Variety.Value == "Normal" then
local function returnSumOfWeight(OreLootTable)
local sum = 0
for _, entry in pairs(OreLootTable) do
sum = sum + entry.Weight
end
return sum
end
local function getRandomItem(OreLootTable)
local randomNumber = math.random(returnSumOfWeight(OreLootTable))
for _, entry in ipairs(OreLootTable) do
if randomNumber <= entry.Weight then
return entry.Item
else
randomNumber = randomNumber - entry.Weight
end
end
end
--Crystal/Ore Generator
local RandomItem = getRandomItem(OreLootTable)
local Item = ss.Drops.Ores:FindFirstChild(RandomItem.Name)
for i = 1, math.random(1,3) do --Grabs a random number between 1-3 and begins a loop
local clone = Item:Clone() --Clones the Ores/Crystals 1-3 times
clone.Parent = workspace --The Cloned Ores/Crystals appear in the Workspace
clone.Position = rockPos --The Clones Ores/Crystals will appear at the rock that was mined
end
elseif Rock.Variety.Value == "Crystal" then
local function returnSumOfWeight(CrystalLootTable)
local sum = 0
for _, entry in pairs(CrystalLootTable) do
sum = sum + entry.Weight
end
return sum
end
local function getRandomItem(CrystalLootTable)--Grabs a random Item from the crystal loot table
local randomNumber = math.random(returnSumOfWeight(CrystalLootTable))
for _, entry in ipairs(CrystalLootTable) do
if randomNumber <= entry.Weight then
return entry.Item
else
randomNumber = randomNumber - entry.Weight
end
end
end
--Crystal/Ore Generator
local RandomItem = getRandomItem(CrystalLootTable) --Grabs a random item from the table
local Item = ss.Drops.Crystals:FindFirstChild(RandomItem.Name) --Finds the random item from the table in ServerStorage
for i = 1, math.random(1,3) do --Grabs a random number between 1-3 and begins a loop
local clone = Item:Clone() --Clones the Ores/Crystals 1-3 times
clone.Parent = workspace --The Cloned Ores/Crystals appear in the Workspace
if clone:IsA("Model")then--Will test if the crystal is a model
clone.PrimaryPart.Position = rockPos --The Clones Ores/Crystals will appear at the rock that was mined
elseif clone:IsA("BasePart")then --Will test if the crystal is a part
clone.Position = rockPos --The Clones Ores/Crystals will appear at the rock that was mined
end
end
end
end
end
wait(0.05)
debounce = false
end
end
end)
Rock.ClickDetector.MouseHoverEnter:Connect(function(player)
game:GetService("ReplicatedStorage").RemoteFunctions.EnableGui:InvokeClient(player, Rock, true)
end)
Rock.ClickDetector.MouseHoverLeave:Connect(function(player)
game:GetService("ReplicatedStorage").RemoteFunctions.EnableGui:InvokeClient(player, Rock, false)
end)
Health:GetPropertyChangedSignal("Value"):Connect(function()
if (Health) then
label.TextLabel.Text = Health.Value.."/"..MaxHealth.Value
end
end)
label.TextLabel.Text = Health.Value.."/"..MaxHealth.Value
end
end
end