Errors: Handle is not a member of tool (on the main script.) and Character is a nil value. (following script.)
Selection script: (localscript in playergui)
--[Locals]--
local player = game.Players.LocalPlayer
local character = player.Character
local mouse = player:GetMouse() --Getting the player's mouse
local folders = workspace.OreBlocks
local tool = script.Parent.Parent.Backpack:WaitForChild("Pickaxe")
local active = false
local humanoid = character.Humanoid
local selection = Instance.new("SelectionBox")
selection.Color3 = Color3.new(255,255,255)
selection.Parent = player.PlayerGui
selection.Name = ("PickaxeSelection")
selection.LineThickness = 0.09
--[Logic]--
mouse.Move:connect(function()
if active and humanoid.Health == 100 then
local target = mouse.Target
if not target then
selection.Adornee = nil
elseif target.Parent == folders then
selection.Adornee = target
else
selection.Adornee = nil
end
end
end)
tool.Equipped:connect(function()
active = true
end)
tool.Unequipped:connect(function()
active = false
selection.Adornee = nil
end)
Main script: (localscript in my pickaxe tool)
--[Made by TheBoxofGhosts]--
--[Locals]--
local mouse = game.Players.LocalPlayer:GetMouse()
local tool = script.Parent
local sound = tool.Handle:WaitForChild("Sound")
local oresound = tool.Handle:WaitForChild("OreSound")
local selection = game.Players.LocalPlayer.PlayerGui:WaitForChild("PickaxeSelection")
--[Logic]--
local function onMining()
if mouse.Target and mouse.Target.Name == ("DirtBlock") then
sound:Play()
script.Disabled = true
selection.Color3 = Color3.new(0, 255, 0)
mouse.Target:Destroy()
wait(0.1)
selection.Color3 = Color3.new(255, 255, 255)
wait(0.2)
script.Disabled = false
end
end
tool.Activated:connect(onMining)
local function onMiningOre()
if mouse.Target and mouse.Target.Name == ("CopperBlock") or mouse.Target and mouse.Target.Name == ("IronBlock") then
oresound:Play()
script.Disabled = true
selection.Color3 = Color3.new(0, 255, 0)
mouse.Target:Destroy()
wait(0.1)
selection.Color3 = Color3.new(255, 255, 255)
wait(0.2)
script.Disabled = false
end
end
tool.Activated:connect(onMiningOre)

3 comments
it's better to use: local character = player.Character or player.CharacterAdded:Wait() instead of a repeat until loop
Thank you! :D
Great idea, MBacon15! Thanks for pointing that out!