So the biggest issue at the moment, is that if theres 2+ rocks inside the game, one cant be mined and the other can be mined, but when you mine the mineable rock, it destroys the unmineable rock.
Shown by my beautiful art and diagram on the top grade emulator.
Im curious on how I could fix this, as I am a little confused.
(by the way the ‘mining’ system is more of a simple click the rock with a pickaxe equipped enough times to clear the route)
Tool Local Script
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local pickaxe = script.Parent
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local Equip = humanoid:LoadAnimation(script.Parent.Equip)
local Idle = humanoid:LoadAnimation(script.Parent.Idle)
local Strike = humanoid:LoadAnimation(script.Parent.Strike)
local debounce = false
pickaxe.Equipped:Connect(function()
Equip:Play()
wait(1.32)
Equip:Stop()
Idle:Play()
end)
pickaxe.Unequipped:Connect(function()
Equip:Stop()
Idle:Stop()
end)
pickaxe.Activated:Connect(function()
wait(.5)
local dist = (character.HumanoidRootPart.Position - mouse.Target.Position).Magnitude
if mouse.Target == game.Workspace.rock and dist < 6 and debounce == false then
debounce = true
Strike:Play()
Idle:Stop()
print("hit rock")
local pickaxeSFX = Instance.new("Sound")
pickaxeSFX.SoundId = "rbxassetid://dontlookatthis:)"
pickaxeSFX.Volume = 2.2
pickaxeSFX.Parent = character.HumanoidRootPart
game.ReplicatedStorage.PickaxeDamage:FireServer()
wait(1.5)
debounce = false
pickaxeSFX:Destroy()
Idle:Play()
else
print("Out of Range / No rock detected")
end
end)
Server Local Script (Inside the rocks that are in the diagram)
local rockHP = 5
game.ReplicatedStorage.PickaxeDamage.OnServerEvent:Connect(function()
rockHP -= 1
if rockHP <= 0 then
script.Parent:Destroy()
end
end)