Question 1,
Is this the best way to check if the target block has changed? The mining blocks Name
is it's position when it's spawned. Also this is in a tool.
local blockValues = game.ServerStorage.Configuration.block_Values local player = game.Players.LocalPlayer local mouse = player:GetMouse() local target local selected_Block = "None" script.Parent.Equipped:connect(function() mouse.Move:connect(function() if mouse.Target then target = mouse.Target if target:FindFirstChild("Type") then if selected_Block == tostring(mouse.Target.Name) then print("Same Block!") else print("Different Block!") selected_Block = mouse.Target.Name end end end end) end)
Question 2, When I unequip the tool, the script keeps printing. How do I stop the script when they unequip the tool?
local equipped = false tool.Equipped:Connect(function(mouse) equipped = true mouse.Move:Connect(function() if equipped then -- code end end) end) tool.Unequipped:Connect(function() -- Mouse isn’t a parameter for Unequipped equipped = false end)