local script:
while true do
wait(1)
if game.Players.LocalPlayer.PlayerGui.ScreenGui:FindFirstChild("mine button coal1") then
print("found button")
if (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - game.Workspace.ores.coal.coal1.Position).magnitude < 5 then
print("should get deleted")
game.Players.LocalPlayer.PlayerGui.ScreenGui:FindFirstChild("mine button coal1"):Destroy()
print("deleted")
end
end
end
prints found button so there is an issue with magnitude line

3 comments
If my answer does not help, you need to edit your question to explain what you are trying to accomplish with your code and what is actually happening.
Shouldn't it be > 5 (more than 5) instead?
it should ye but it didnt work when it was less than 5